-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: update default policy deny all
Signed-off-by: Christopher Phillips <[email protected]>
- Loading branch information
Showing
7 changed files
with
106 additions
and
12 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
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
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 |
---|---|---|
@@ -1 +1,39 @@ | ||
package cli | ||
|
||
import ( | ||
"os/exec" | ||
"strings" | ||
"testing" | ||
) | ||
|
||
func Test_CheckCmd(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
args []string | ||
expectedInOutput []string | ||
}{ | ||
{ | ||
name: "check command will deny all on empty config", | ||
args: []string{"-c", emptyConfigPath, "check", "dir:../../."}, | ||
expectedInOutput: []string{ | ||
"check failed", | ||
"license matches for rule: default-deny-all; matched with pattern *", | ||
"Apache-2.0", | ||
}, | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
cmd := exec.Command(grantTmpPath, tt.args...) | ||
output, err := cmd.CombinedOutput() | ||
if err != nil && !strings.Contains(err.Error(), "exit status 1") { | ||
t.Fatalf("cmd.CombinedOutput() failed with %s\n %s", err, string(output)) | ||
} | ||
for _, expected := range tt.expectedInOutput { | ||
if !strings.Contains(string(output), expected) { | ||
t.Errorf("expected %s to be in output, but it wasn't; output: %s", expected, string(output)) | ||
} | ||
} | ||
}) | ||
} | ||
} |
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