-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(testutils): export CheckAnyConstraint
It is also useful for backup svc tests.
- Loading branch information
1 parent
f371ebc
commit 47bbcf1
Showing
4 changed files
with
42 additions
and
28 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// Copyright (C) 2024 ScyllaDB | ||
|
||
package testutils | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/scylladb/scylla-manager/v3/pkg/scyllaclient" | ||
"github.com/scylladb/scylla-manager/v3/pkg/util/version" | ||
) | ||
|
||
// CheckAnyConstraint checks if any of the passed version constraints are satisfied. | ||
// Can be used for skipping tests which make sense only for certain Scylla versions. | ||
func CheckAnyConstraint(t *testing.T, client *scyllaclient.Client, constraints ...string) bool { | ||
t.Helper() | ||
|
||
ni, err := client.AnyNodeInfo(context.Background()) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
for _, c := range constraints { | ||
ok, err := version.CheckConstraint(ni.ScyllaVersion, c) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
if ok { | ||
return true | ||
} | ||
} | ||
return false | ||
} |