Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[VC-35738] Move the agent --one-shot test to the cmd package #610

Merged
merged 1 commit into from
Nov 12, 2024

Conversation

wallrj
Copy link
Member

@wallrj wallrj commented Nov 7, 2024

Instead of duplicating the log initailization and exit behaviour of the Execute function,
I moved this test to the cmd package where I can simply run the Execute function directly.

This simplifies the test and avoids the test and implementation getting out of sync.

$ go test ./cmd/... -v
=== RUN   TestAgentRunOneShot
    agent_test.go:41: Running child process
    agent_test.go:59: STDOUT
        I1107 13:27:46.472452  276234 logs.go:153] "Preflight agent version: development ()" source="agent"
        I1107 13:27:46.472578  276234 logs.go:153] "Using the Jetstack Secure API Token auth mode since --api-token was specified." source="agent"
        I1107 13:27:46.472594  276234 run.go:119] "Healthz endpoints enabled" logger="APIServer" addr=":8081" path="/healthz"
        I1107 13:27:46.472605  276234 run.go:123] "Readyz endpoints enabled" logger="APIServer" addr=":8081" path="/readyz"
        I1107 13:27:46.472668  276234 run.go:460] "Starting" logger="APIServer.ListenAndServe" addr=":8081"
        I1107 13:27:46.473314  276234 logs.go:153] "Reading data from local file: testdata/agent/one-shot/success/input.json" source="agent"
        I1107 13:27:46.473378  276234 logs.go:153] "Data saved to local file: /dev/null" source="agent"
        I1107 13:27:46.473393  276234 run.go:474] "Shutting down" logger="APIServer.ListenAndServe" addr=":8081"
        I1107 13:27:46.473439  276234 run.go:489] "Shutdown complete" logger="APIServer.ListenAndServe" addr=":8081"

    agent_test.go:60: STDERR

--- PASS: TestAgentRunOneShot (0.02s)
PASS
ok      github.com/jetstack/preflight/cmd       0.045s

And use the Execute function

Signed-off-by: Richard Wall <richard.wall@venafi.com>
@wallrj wallrj merged commit 45a5d77 into VC-35738/feature Nov 12, 2024
2 checks passed
@wallrj wallrj deleted the VC-35738/move-one-shot-test branch November 12, 2024 06:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants