agent-substrate / agent-substrate/substrate

Suggestion: Refactor koApply to an Exported Helper

Abierto
#1,251 0 comentarios 0 reacciones 0 asignados Ver en GitHub
area/tests good first issue kind/cleanup
Lenguaje dominante
Go
Estrellas
1.8k
Forks
316
Merge medio
2 d 43 min
PR fusionados (30 d)
287

Descripción

# Refactor `koApply` to an Exported Helper

There is a piece of technical debt in the repository causing test developers to duplicate the `ko apply` logic across all the E2E suites. The `koApply` function in the shared E2E package was accidentally written unexported. Please refactor this to be exported and DRY out the test suites.

## Tasks
1. **Export the Helper**
- Open `internal/e2e/manifest.go`.
- Rename the `koApply` function to `KoApply` so it's exported and accessible outside the package.
- Update its associated godoc comment to match the exported name.

2. **Deduplicate the Test Suites**
- Scan the test files in `internal/e2e/suites/` (specifically `networking/websocket_test.go`, `sizing/sizing_test.go`, `egressauthz/egressauthz_test.go`, and `capabilities/capabilities_test.go`).
- Find the blocks of code inside their respective `deployXFixture` functions that manually execute `ko apply`. It typically looks like this:
```go
applyArgs := []string{"ko", "apply", "-f", manifest}
if e2e.KubeContext != "" {
applyArgs = append(applyArgs, "--", "--context="+e2e.KubeContext)
}
e2e.RunCmdWithEnv(t, []string{"KO_CONFIG_PATH=" + root}, filepath.Join(root, "hack/run-tool.sh"), applyArgs...)
```
- Delete these 5-to-8 lines of duplicate code in each test file and replace them with a simple call to our newly exported helper:
```go
e2e.KoApply(t, manifest)
```

## Verification
- Run `make verify` to ensure the Go source still passes `gofmt` and there are no unused imports.
- Ensure that the tests compile without errors.

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.