agent-substrate / agent-substrate/substrate

Suggestion: Refactor koApply to an Exported Helper

Open
#1,251 0 comments 0 reactions 0 assignees View on GitHub
area/tests good first issue kind/cleanup
Dominant language
Go
Stars
1.8k
Forks
316
Avg merge
2d 43m
Merged PRs (30d)
287

Description

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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.