Skip to content

Commit

Permalink
test(nuke): improve test coverage of error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
ekristen committed Oct 15, 2024
1 parent 6a1c8bb commit 53c345d
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions pkg/nuke/nuke_filter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,45 @@ func Test_NukeFiltersMatchGroups_NoMatch(t *testing.T) {
assert.Equal(t, 1, n.Queue.Count(queue.ItemStateFiltered))
}

func Test_NukeFiltersMatchGroups_NoMatch_WithError(t *testing.T) {
registry.ClearRegistry()
registry.Register(TestResourceRegistration2)

filters := filter.Filters{
TestResourceType2: []filter.Filter{
{
Type: filter.Exact,
Property: "test",
Value: "testing",
Group: "group1",
},
{
Type: filter.Regex,
Property: "test2",
Value: "^(testing$",
Group: "group2",
},
},
}

n := New(testParametersGroups, filters, nil)
n.SetLogger(logrus.WithField("test", true))
n.SetRunSleep(time.Millisecond * 5)

opts := TestOpts{
SessionOne: "testing",
SecondResource: true,
}
newScanner := scanner.New("Owner", []string{TestResourceType2}, opts)

sErr := n.RegisterScanner(testScope, newScanner)
assert.NoError(t, sErr)

err := n.Scan(context.TODO())
assert.Error(t, err)
assert.Equal(t, "error parsing regexp: missing closing ): `^(testing$`", err.Error())
}

func Test_NukeFiltersMatchInverted(t *testing.T) {
registry.ClearRegistry()
registry.Register(TestResourceRegistration2)
Expand Down

0 comments on commit 53c345d

Please sign in to comment.