Skip to content

Commit

Permalink
Return a *state in modState
Browse files Browse the repository at this point in the history
  • Loading branch information
jjti committed Jan 29, 2024
1 parent f76ffc7 commit 5fb409f
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions pkg/hcp/telemetry/exporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ func Test_Exporter(t *testing.T) {
t.Parallel()

for name, tc := range map[string]struct {
modState func(*state)
nilState bool // nil state entirely
modState func(*state) *state
scrapeErr error
exportErr error

Expand All @@ -81,12 +80,15 @@ func Test_Exporter(t *testing.T) {
expectExport: true,
},
"disabled": {
modState: func(s *state) {
modState: func(s *state) *state {
s.disabled = true
return s
},
},
"disabled nil state": {
nilState: true,
modState: func(s *state) *state {
return nil
},
},
"failure scrape": {
scrapeErr: errors.New("failed to scrape"),
Expand Down Expand Up @@ -122,10 +124,7 @@ func Test_Exporter(t *testing.T) {
includeList: []string{"a", "b"},
}
if tc.modState != nil {
tc.modState(state)
}
if tc.nilState {
state = nil
state = tc.modState(state)
}

// Create fake scraper and state tracker.
Expand Down

0 comments on commit 5fb409f

Please sign in to comment.