-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #53 from jacobbednarz/skip-aws-service-roles
Add support for skipping AWS service roles
- Loading branch information
Showing
2 changed files
with
79 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package iamy | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestIsSkippableManagedResource(t *testing.T) { | ||
skippables := []string{ | ||
"myalias-123/iam/role/aws-service-role/spot.amazonaws.com/AWSServiceRoleForEC2Spot.yaml", | ||
"AWSServiceRoleTest", | ||
"my-example-role-ABCDEFGH1234567", | ||
} | ||
|
||
nonSkippables := []string{ | ||
"myalias-123/iam/user/foo/billy.blogs.yaml", | ||
"myalias-123/s3/my-bucket.yaml", | ||
"myalias-123/iam/instance-profile/example.yaml", | ||
} | ||
|
||
for _, name := range skippables { | ||
t.Run(name, func(t *testing.T) { | ||
|
||
skipped, err := isSkippableManagedResource(name) | ||
if skipped == false { | ||
t.Errorf("expected %s to be skipped but got false", name) | ||
} | ||
|
||
if err == "" { | ||
t.Errorf("expected %s to output an error message but it was empty", name) | ||
} | ||
}) | ||
} | ||
|
||
for _, name := range nonSkippables { | ||
t.Run(name, func(t *testing.T) { | ||
|
||
skipped, err := isSkippableManagedResource(name) | ||
if skipped == true { | ||
t.Errorf("expected %s to not be skipped but got true", name) | ||
} | ||
|
||
if err != "" { | ||
t.Errorf("expected %s to not output an error message but got: %s", name, err) | ||
} | ||
}) | ||
} | ||
} |