-
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.
CLOUDP-294932: Fix contract test skips (#2049)
* Fix contract test skips Signed-off-by: jose.vazquez <[email protected]> * Update test/helper/contract/contract.go Use simpler non parameterised error constructor Co-authored-by: Sergiusz Urbaniak <[email protected]> * fixup Signed-off-by: jose.vazquez <[email protected]> --------- Signed-off-by: jose.vazquez <[email protected]> Co-authored-by: Sergiusz Urbaniak <[email protected]>
- Loading branch information
1 parent
a04982b
commit 8b2869c
Showing
2 changed files
with
81 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,67 @@ | ||
package contract | ||
|
||
import ( | ||
"errors" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestSkip(t *testing.T) { | ||
for _, tc := range []struct { | ||
title string | ||
name string | ||
focus string | ||
enabled bool | ||
expected error | ||
}{ | ||
{ | ||
title: "empty name, focus and disabled skips all", | ||
expected: errors.New("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: errors.New("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: errors.New("test \"something else\" does not contain focus string \"target\""), | ||
}, | ||
{ | ||
title: "enabled with matching focus does not skip", | ||
enabled: true, | ||
name: "target", | ||
focus: "target", | ||
}, | ||
{ | ||
title: "enabled matching a sub-target focus does not skip", | ||
enabled: true, | ||
name: "some target phrase", | ||
focus: "target", | ||
}, | ||
} { | ||
t.Run(tc.title, func(t *testing.T) { | ||
err := skipCheck(tc.name, tc.focus, tc.enabled) | ||
assert.Equal(t, tc.expected, err) | ||
}) | ||
} | ||
} |