agent-substrate / agent-substrate/substrate

Suggestion: Refactor koApply to an Exported Helper

Đang mở
#1,251 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
area/tests good first issue kind/cleanup
Ngôn ngữ chính
Go
Star
1.8k
Fork
316
Merge trung bình
2 ngày 43 phút
Pull request đã merge (30 ngày)
287

Mô tả

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

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.