agent-substrate / agent-substrate/substrate

Suggestion: Refactor koApply to an Exported Helper

Aperta
#1,251 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
area/tests good first issue kind/cleanup
Lingua principale
Go
Stelle
1.8k
Fork
316
Merge medio
2g 43m
PR unite (30g)
287

Descrizione

# 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.

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.