diff --git a/pkg/aa/parse_test.go b/pkg/aa/parse_test.go index 3bfc1eae..9cc011f3 100644 --- a/pkg/aa/parse_test.go +++ b/pkg/aa/parse_test.go @@ -14,7 +14,7 @@ import ( func Test_tokenizeRule(t *testing.T) { inHeader = true - for _, tt := range testRules { + for _, tt := range testParseRules { t.Run(tt.name, func(t *testing.T) { if got := tokenizeRule(tt.raw); !reflect.DeepEqual(got, tt.tokens) { t.Errorf("tokenize() = %v, want %v", got, tt.tokens) @@ -25,7 +25,7 @@ func Test_tokenizeRule(t *testing.T) { func Test_parseRule(t *testing.T) { inHeader = true - for _, tt := range testRules { + for _, tt := range testParseRules { t.Run(tt.name, func(t *testing.T) { if got := parseRule(tt.raw); !reflect.DeepEqual(got, tt.rule) { t.Errorf("parseRule() = %v, want %v", got, tt.rule) @@ -35,7 +35,7 @@ func Test_parseRule(t *testing.T) { } func Test_rule_Getter(t *testing.T) { - for _, tt := range testRules { + for _, tt := range testParseRules { t.Run(tt.name, func(t *testing.T) { if tt.wGetAsMap == nil { tt.wGetAsMap = map[string][]string{} @@ -113,7 +113,7 @@ func Test_parseCommaRules(t *testing.T) { } func Test_newRules(t *testing.T) { - for _, tt := range testRules { + for _, tt := range testParseRules { if tt.wRule == nil { continue } @@ -159,7 +159,7 @@ func Test_AppArmorProfileFile_Parse(t *testing.T) { var ( // Test cases for tokenizeRule, parseRule,rule getters, and newRules - testRules = []struct { + testParseRules = []struct { name string raw string tokens []string @@ -497,7 +497,7 @@ var ( wString: "signal receive set=(cont term winch) peer=at-spi-bus-launcher", wRule: &Signal{ Access: []string{"receive"}, - Set: []string{"term", "cont", "winch"}, + Set: []string{"cont", "term", "winch"}, Peer: "at-spi-bus-launcher", }, }, @@ -1123,7 +1123,7 @@ var ( { &Signal{ Access: []string{"receive"}, - Set: []string{"term", "cont", "winch"}, + Set: []string{"cont", "term", "winch"}, Peer: "at-spi-bus-launcher", }, }, diff --git a/pkg/aa/rules_test.go b/pkg/aa/rule_test.go similarity index 98% rename from pkg/aa/rules_test.go rename to pkg/aa/rule_test.go index b3aa67b7..77e05e32 100644 --- a/pkg/aa/rules_test.go +++ b/pkg/aa/rule_test.go @@ -9,7 +9,7 @@ import ( "testing" ) -func TestRules_FromLog(t *testing.T) { +func TestRule_FromLog(t *testing.T) { for _, tt := range testRule { if tt.fromLog == nil { continue @@ -22,27 +22,7 @@ func TestRules_FromLog(t *testing.T) { } } -func TestRules_Validate(t *testing.T) { - for _, tt := range testRule { - t.Run(tt.name, func(t *testing.T) { - if err := tt.rule.Validate(); (err != nil) != tt.wValidErr { - t.Errorf("Rules.Validate() error = %v, wantErr %v", err, tt.wValidErr) - } - }) - } -} - -func TestCapability_Compare(t *testing.T) { - for _, tt := range testRule { - t.Run(tt.name, func(t *testing.T) { - if got := tt.rule.Compare(tt.other); got != tt.wCompare { - t.Errorf("Rule.Compare() = %v, want %v", got, tt.wCompare) - } - }) - } -} - -func TestRules_String(t *testing.T) { +func TestRule_String(t *testing.T) { for _, tt := range testRule { t.Run(tt.name, func(t *testing.T) { if got := tt.rule.String(); got != tt.wString { @@ -52,7 +32,27 @@ func TestRules_String(t *testing.T) { } } -func TestCapability_Merge(t *testing.T) { +func TestRule_Validate(t *testing.T) { + for _, tt := range testRule { + t.Run(tt.name, func(t *testing.T) { + if err := tt.rule.Validate(); (err != nil) != tt.wValidErr { + t.Errorf("Rules.Validate() error = %v, wantErr %v", err, tt.wValidErr) + } + }) + } +} + +func TestRule_Compare(t *testing.T) { + for _, tt := range testRule { + t.Run(tt.name, func(t *testing.T) { + if got := tt.rule.Compare(tt.other); got != tt.wCompare { + t.Errorf("Rule.Compare() = %v, want %v", got, tt.wCompare) + } + }) + } +} + +func TestRule_Merge(t *testing.T) { for _, tt := range testRule { t.Run(tt.name, func(t *testing.T) { if got := tt.rule.Merge(tt.other); got != tt.wMerge {