Skip to content

Commit

Permalink
Add more tests
Browse files Browse the repository at this point in the history
Signed-off-by: Ihor Hrytskiv <[email protected]>
  • Loading branch information
ihor-hrytskiv committed Sep 5, 2024
1 parent 0e084f4 commit ce74de3
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions github/repos_rules_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ func TestRepositoryRule_UnmarshalJSON(t *testing.T) {
},
wantErr: true,
},
"Required workflows params": {
"Valid Required workflows params": {
data: `{"type":"workflows","parameters":{"workflows":[{"path": ".github/workflows/test.yml", "repository_id": 1}]}}`,
want: NewRequiredWorkflowsRule(&RequiredWorkflowsRuleParameters{
RequiredWorkflows: []*RuleRequiredWorkflow{
Expand All @@ -304,7 +304,15 @@ func TestRepositoryRule_UnmarshalJSON(t *testing.T) {
},
}),
},
"Required code_scanning params": {
"Invalid Required workflows params": {
data: `{"type":"workflows","parameters":{"workflows":[{"path": ".github/workflows/test.yml", "repository_id": "test"}]}}`,
want: &RepositoryRule{
Type: "workflows",
Parameters: nil,
},
wantErr: true,
},
"Valid Required code_scanning params": {
data: `{"type":"code_scanning","parameters":{"code_scanning_tools":[{"tool": "CodeQL", "security_alerts_threshold": "high_or_higher", "alerts_threshold": "errors"}]}}`,
want: NewRequiredCodeScanningRule(&RequiredCodeScanningRuleParameters{
RequiredCodeScanningTools: []*RuleRequiredCodeScanningTools{
Expand All @@ -316,6 +324,14 @@ func TestRepositoryRule_UnmarshalJSON(t *testing.T) {
},
}),
},
"Invalid Required code_scanning params": {
data: `{"type":"code_scanning","parameters":{"code_scanning_tools":[{"tool": 1}]}}`,
want: &RepositoryRule{
Type: "code_scanning",
Parameters: nil,
},
wantErr: true,
},
"Invalid type": {
data: `{"type":"unknown"}`,
want: &RepositoryRule{
Expand Down

0 comments on commit ce74de3

Please sign in to comment.