-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- 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,66 @@ | ||
package contract | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestSkip(t *testing.T) { | ||
for _, tc := range []struct { | ||
title string | ||
name string | ||
focus string | ||
enabled bool | ||
expected string | ||
}{ | ||
{ | ||
title: "empty name, focus and disabled skips all", | ||
expected: "Skipping contract test as AKO_CONTRACT_TEST is unset", | ||
}, | ||
{ | ||
title: "empty name, focus and enabled does not skip", | ||
enabled: true, | ||
}, | ||
{ | ||
title: "disabled skips regardles of focus matching", | ||
name: "target", | ||
focus: "target", | ||
expected: "Skipping contract test as AKO_CONTRACT_TEST is unset", | ||
}, | ||
{ | ||
title: "enabled with no focus does not skip", | ||
enabled: true, | ||
name: "target", | ||
}, | ||
{ | ||
title: "enabled with no focus does not skip", | ||
enabled: true, | ||
name: "target", | ||
}, | ||
{ | ||
title: "enabled with non matching focus skips", | ||
enabled: true, | ||
name: "something else", | ||
focus: "target", | ||
expected: "Skipping contract test \"something else\" as it does not contain focus string \"target\"", | ||
}, | ||
{ | ||
title: "enabled with matching focus does not skip", | ||
enabled: true, | ||
name: "target", | ||
focus: "target", | ||
}, | ||
{ | ||
title: "enabled matching a sugtarget focus does not skip", | ||
enabled: true, | ||
name: "some target phrase", | ||
focus: "target", | ||
}, | ||
} { | ||
t.Run(tc.title, func(t *testing.T) { | ||
skipReason := skipCheck(tc.name, tc.focus, tc.enabled) | ||
assert.Equal(t, tc.expected, skipReason) | ||
}) | ||
} | ||
} |