Skip to content

Commit

Permalink
test: add DontWantOutput for TestSSO
Browse files Browse the repository at this point in the history
  • Loading branch information
Integralist committed Nov 14, 2023
1 parent 1dad712 commit 6822a03
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
14 changes: 8 additions & 6 deletions pkg/commands/sso/sso_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,14 +163,12 @@ func TestSSO(t *testing.T) {
// We set an SSO token that has expired.
// This allows us to validate the output message about expiration.
// We don't respond "Y" to prompt to reauthenticate.
// But we've mocked the request to succeeds still so it doesn't matter.
// But we've mocked the request to succeed still so it doesn't matter.
{
TestScenario: testutil.TestScenario{
Args: args("whoami"),
WantOutputs: []string{
"Your access token has expired and so has your refresh token.",
"Alice Programmer <alice@example.com>",
},
Args: args("whoami"),
WantOutput: "Your access token has expired and so has your refresh token.",
DontWantOutput: "Alice Programmer <alice@example.com>",
},
ConfigFile: &config.File{
Profiles: config.Profiles{
Expand Down Expand Up @@ -326,6 +324,10 @@ func TestSSO(t *testing.T) {
} else {
testutil.AssertStringContains(t, stdout.String(), testcase.WantOutput)
}

for _, s := range testcase.DontWantOutputs {
testutil.AssertStringDoesntContain(t, stdout.String(), s)
}
})
}
}
14 changes: 8 additions & 6 deletions pkg/testutil/scenarios.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ import "github.com/fastly/cli/pkg/mock"

// TestScenario represents a standard test case to be validated.
type TestScenario struct {
API mock.API
Args []string
Name string
WantError string
WantOutput string
WantOutputs []string
API mock.API
Args []string
DontWantOutput string
DontWantOutputs []string
Name string
WantError string
WantOutput string
WantOutputs []string
}

0 comments on commit 6822a03

Please sign in to comment.