Skip to content

Commit

Permalink
test: assert the error string when the environment variable is missing
Browse files Browse the repository at this point in the history
This change fixes a test that returns a false-positive. This occurred
because previously the check was for *any* error, not specifically
if the required environment variable was missing. This is fixed by
checking the error message, rather than naively checking for any error.
  • Loading branch information
therealvio committed Dec 4, 2024
1 parent 303102b commit 24aff23
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/plugin/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ func TestFailOnMissingEnvironment(t *testing.T) {

err := fetcher.Fetch(&config)

assert.NotNil(t, err, "fetch should error")
expectedErr := "required key BUILDKITE_PLUGIN_EXAMPLE_GO_MESSAGE missing value"
assert.EqualError(t, err, expectedErr, "fetch should error on missing environment variable")
}

func TestFetchConfigFromEnvironment(t *testing.T) {
Expand Down

0 comments on commit 24aff23

Please sign in to comment.