Skip to content

Commit

Permalink
Update tests: key access rights are no longer relevant to Setters
Browse files Browse the repository at this point in the history
  • Loading branch information
EduardGomezEscandell committed Oct 27, 2023
1 parent 5c2effc commit 3418252
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions windows-agent/internal/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,10 +267,8 @@ func TestSetSubscription(t *testing.T) {
t.Parallel()

testCases := map[string]struct {
mockErrors uint32
settingsState settingsState
accessIsReadOnly bool
emptyToken bool
settingsState settingsState
emptyToken bool

want string
wantError bool
Expand All @@ -280,11 +278,6 @@ func TestSetSubscription(t *testing.T) {
"Success when the key does not exist": {settingsState: untouched, want: "new_token"},
"Success when the pro token field does not exist": {settingsState: keyExists, want: "new_token"},
"Success when there is a store token active": {settingsState: storeTokenHasValue, want: "store_token"},

"Error when the registry key cannot be written on due to lack of permission": {settingsState: userTokenHasValue, accessIsReadOnly: true, want: "user_token", wantError: true},
"Error when the registry key cannot be opened": {settingsState: userTokenHasValue, mockErrors: registry.MockErrOnCreateKey, want: "user_token", wantError: true},
"Error when the registry key cannot be written on": {settingsState: userTokenHasValue, mockErrors: registry.MockErrOnWriteValue, want: "user_token", wantError: true},
"Error when the registry key cannot be read": {settingsState: userTokenHasValue, mockErrors: registry.MockErrOnOpenKey, want: "user_token", wantError: true},
}

for name, tc := range testCases {
Expand All @@ -293,7 +286,7 @@ func TestSetSubscription(t *testing.T) {
t.Parallel()
ctx := context.Background()

r, dir := setUpMockSettings(t, tc.mockErrors, tc.settingsState, tc.accessIsReadOnly, false)
r, dir := setUpMockSettings(t, 0, tc.settingsState, false, false)
conf := config.New(ctx, dir, config.WithRegistry(r))

token := "new_token"
Expand Down

0 comments on commit 3418252

Please sign in to comment.