forked from rancher/rancher
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Adds a new quarantine package that has a function to quarantine…
… tests. Updates existing test skips to this quarantine test function. Closes [rancher/qa-tasks/issues/1484].
- Loading branch information
1 parent
323c427
commit 2fc86c4
Showing
10 changed files
with
51 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package quarantine | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/rancher/shepherd/pkg/environmentflag" | ||
) | ||
|
||
// Quarantine package's Test method skips the given testing T by default when it's used | ||
// to run quarantine flag, the flag in the configuration needs to be set like: | ||
// | ||
// flags: | ||
// desiredflags: quarantined | ||
// | ||
// or multiple flags with quarantine option: | ||
// | ||
// flags: | ||
// desiredflags: quarantined|long|otherFlag | ||
|
||
func Test(t *testing.T, args ...any) { | ||
environmentFlags := environmentflag.NewEnvironmentFlags() | ||
environmentflag.LoadEnvironmentFlags(environmentflag.ConfigurationFileKey, environmentFlags) | ||
|
||
quarantined := fmt.Sprintf("Test [%v] is quarantined, skipping:", t.Name()) | ||
|
||
reason := append([]any{quarantined}, args...) | ||
|
||
if !environmentFlags.GetValue(environmentflag.Quarantined) { | ||
t.Skip(reason) | ||
} | ||
} |
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
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