Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
| 1 | 1 |
deleted file mode 100644 |
| ... | ... |
@@ -1,30 +0,0 @@ |
| 1 |
-package requirement |
|
| 2 |
- |
|
| 3 |
-import ( |
|
| 4 |
- "path" |
|
| 5 |
- "reflect" |
|
| 6 |
- "runtime" |
|
| 7 |
- "strings" |
|
| 8 |
- "testing" |
|
| 9 |
-) |
|
| 10 |
- |
|
| 11 |
-// Test represent a function that can be used as a requirement validation. |
|
| 12 |
-type Test func() bool |
|
| 13 |
- |
|
| 14 |
-// Is checks if the environment satisfies the requirements |
|
| 15 |
-// for the test to run or skips the tests. |
|
| 16 |
-func Is(t *testing.T, requirements ...Test) {
|
|
| 17 |
- t.Helper() |
|
| 18 |
- for _, r := range requirements {
|
|
| 19 |
- isValid := r() |
|
| 20 |
- if !isValid {
|
|
| 21 |
- requirementFunc := runtime.FuncForPC(reflect.ValueOf(r).Pointer()).Name() |
|
| 22 |
- t.Skipf("unmatched requirement %s", extractRequirement(requirementFunc))
|
|
| 23 |
- } |
|
| 24 |
- } |
|
| 25 |
-} |
|
| 26 |
- |
|
| 27 |
-func extractRequirement(requirementFunc string) string {
|
|
| 28 |
- requirement := path.Base(requirementFunc) |
|
| 29 |
- return strings.SplitN(requirement, ".", 2)[1] |
|
| 30 |
-} |
| ... | ... |
@@ -6,13 +6,15 @@ import ( |
| 6 | 6 |
"net/http" |
| 7 | 7 |
"os" |
| 8 | 8 |
"os/exec" |
| 9 |
+ "path" |
|
| 10 |
+ "reflect" |
|
| 11 |
+ "runtime" |
|
| 9 | 12 |
"strings" |
| 10 | 13 |
"testing" |
| 11 | 14 |
"time" |
| 12 | 15 |
|
| 13 | 16 |
"github.com/containerd/containerd/v2/plugins" |
| 14 | 17 |
"github.com/docker/docker/integration-cli/cli" |
| 15 |
- "github.com/docker/docker/integration-cli/requirement" |
|
| 16 | 18 |
"github.com/docker/docker/testutil/registry" |
| 17 | 19 |
"github.com/moby/moby/api/types/network" |
| 18 | 20 |
"github.com/moby/moby/api/types/swarm" |
| ... | ... |
@@ -165,7 +167,13 @@ func DockerCLIVersion(t testing.TB) string {
|
| 165 | 165 |
|
| 166 | 166 |
// testRequires checks if the environment satisfies the requirements |
| 167 | 167 |
// for the test to run or skips the tests. |
| 168 |
-func testRequires(t *testing.T, requirements ...requirement.Test) {
|
|
| 168 |
+func testRequires(t *testing.T, requirements ...func() bool) {
|
|
| 169 | 169 |
t.Helper() |
| 170 |
- requirement.Is(t, requirements...) |
|
| 170 |
+ for _, check := range requirements {
|
|
| 171 |
+ if !check() {
|
|
| 172 |
+ requirementFunc := runtime.FuncForPC(reflect.ValueOf(check).Pointer()).Name() |
|
| 173 |
+ _, req, _ := strings.Cut(path.Base(requirementFunc), ".") |
|
| 174 |
+ t.Skipf("unmatched requirement %s", req)
|
|
| 175 |
+ } |
|
| 176 |
+ } |
|
| 171 | 177 |
} |