Skip to content

Commit

Permalink
feat: add RunIfSpecsAreEnabled
Browse files Browse the repository at this point in the history
  • Loading branch information
laurentsenta committed Apr 7, 2023
1 parent 0fa2fe7 commit d2c690c
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 13 deletions.
21 changes: 11 additions & 10 deletions tests/t0109_gateway_web_redirects_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,11 +306,11 @@ func TestRedirectsFileSupport(t *testing.T) {
}...)
}

if specs.SubdomainGateway.IsEnabled() {
Run(t, helpers.UnwrapSubdomainTests(t, tests))
} else {
t.Skip("subdomain gateway disabled")
}
RunIfSpecsAreEnabled(
t,
helpers.UnwrapSubdomainTests(t, tests),
specs.SubdomainGateway,
)
}

func TestRedirectsFileSupportWithDNSLink(t *testing.T) {
Expand Down Expand Up @@ -398,9 +398,10 @@ func TestRedirectsFileSupportWithDNSLink(t *testing.T) {
// },
}

if specs.DNSLinkResolver.IsEnabled() {
Run(t, helpers.UnwrapSubdomainTests(t, tests))
} else {
t.Skip("subdomain gateway disabled")
}
RunIfSpecsAreEnabled(
t,
helpers.UnwrapSubdomainTests(t, tests),
specs.DNSLinkResolver,
specs.SubdomainGateway,
)
}
4 changes: 3 additions & 1 deletion tooling/specs/specs.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package specs

import "fmt"
import (
"fmt"
)

type maturity string

Expand Down
23 changes: 21 additions & 2 deletions tooling/test/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"testing"

"github.com/ipfs/gateway-conformance/tooling/check"
"github.com/ipfs/gateway-conformance/tooling/specs"
)

type SugarTest struct {
Expand All @@ -19,9 +20,27 @@ type SugarTest struct {

type SugarTests []SugarTest

func Run(t *testing.T, tests SugarTests) {
// NewDialer()
func RunIfSpecsAreEnabled(
t *testing.T,
tests SugarTests,
required ...specs.Spec,
) {
missing := []specs.Spec{}
for _, spec := range required {
if !spec.IsEnabled() {
missing = append(missing, spec)
}
}

if len(missing) > 0 {
t.Skipf("skipping tests, missing specs: %v", missing)
return
}

Run(t, tests)
}

func Run(t *testing.T, tests SugarTests) {
for _, test := range tests {
t.Run(test.Name, func(t *testing.T) {
method := test.Request.Method_
Expand Down

0 comments on commit d2c690c

Please sign in to comment.