Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
EyalDelarea committed Nov 10, 2024
1 parent 604d74b commit 197779f
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion common/commands/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -363,9 +363,21 @@ func TestCommandName(t *testing.T) {
assert.NoError(t, err)
}

// Test both cases of the ExecAndReportUsage function
// Usage should be sent only when the environment variable is set
// Validate no errors
func TestConfigCommand_ExecAndReportUsage(t *testing.T) {
// With usage report
err := os.Setenv(coreutils.UsageOidcConfigured, "TRUE")
assert.NoError(t, err)
cc := NewConfigCommand(AddOrEdit, testServerId)
err := cc.ExecAndReportUsage()
err = cc.ExecAndReportUsage()
assert.NoError(t, err)
// Without usage report
err = os.Unsetenv(coreutils.UsageOidcConfigured)
assert.NoError(t, err)
cc = NewConfigCommand(AddOrEdit, testServerId)
err = cc.ExecAndReportUsage()
assert.NoError(t, err)
}

Expand Down

0 comments on commit 197779f

Please sign in to comment.