Skip to content

Commit 0dcef78

Browse files
Test case correction
1 parent 07db916 commit 0dcef78

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

internal/commands/auth_test.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,15 @@ func TestAuthValidateMissingFlagsTogether(t *testing.T) {
2929

3030
func TestAuthValidateInvalidAPIKey(t *testing.T) {
3131
err := executeTestCommand(createASTTestCommand(), "auth", "validate", "--apikey", "invalidApiKey")
32-
assertError(t, err, fmt.Sprintf(wrappers.APIKeyDecodeErrorFormat, ""))
32+
if err == nil {
33+
t.Log("TestAuthValidateInvalidAPIKey:error is nil")
34+
} else {
35+
t.Logf("TestAuthValidateInvalidAPIKey:error is %q", err.Error())
36+
}
37+
expectedMsg := fmt.Sprintf(wrappers.APIKeyDecodeErrorFormat, "")
38+
t.Logf("TestAuthValidateInvalidAPIKey: expected message fragment = %q", expectedMsg)
39+
40+
assertError(t, err, expectedMsg)
3341
}
3442

3543
func TestRunCreateOath2ClientCommand(t *testing.T) {

internal/commands/root_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,12 @@ func execCmdNotNilAssertion(t *testing.T, args ...string) error {
207207
}
208208

209209
func assertError(t *testing.T, err error, expectedMessage string) {
210+
if err == nil {
211+
t.Log("assetError:err is nil")
212+
} else {
213+
t.Logf("assetError:actual error =%q", err.Error())
214+
}
215+
t.Logf("asseetError:expected error =%q", expectedMessage)
210216
assert.Assert(t, err != nil)
211217
assert.Assert(t, strings.Contains(strings.ToLower(err.Error()), strings.ToLower(expectedMessage)))
212218
}

0 commit comments

Comments
 (0)