Skip to content

Commit fa13a70

Browse files
committed
switch integration tests from tags to in-code explicit tests for easier management
Signed-off-by: Avi Deitcher <avi@deitcher.net>
1 parent 965db92 commit fa13a70

File tree

7 files changed

+27
-11
lines changed

7 files changed

+27
-11
lines changed

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ push: build
3535
docker push $(TARGET)
3636

3737
integration_test:
38-
go test -v ./test --tags=integration
38+
TEST_INTEGRATION=true go test -v ./test
3939

4040
integration_test_debug:
41-
dlv --wd=./test test ./test --build-flags="-tags=integration"
41+
TEST_INTEGRATION=true dlv --wd=./test test ./test
4242

4343
vet:
4444
go vet --tags=integration ./...

test/backup_log_containers.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//go:build integration && !logs
1+
//go:build !logs
22

33
package test
44

test/backup_nolog_containers.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//go:build integration && logs
1+
//go:build logs
22

33
package test
44

test/backup_teardown_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
//go:build integration
2-
31
package test
42

53
import "fmt"

test/backup_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
//go:build integration
2-
31
package test
42

53
import (
@@ -931,6 +929,7 @@ log_queries_not_using_indexes = 1
931929
}
932930

933931
func TestIntegration(t *testing.T) {
932+
CheckSkipIntegration(t, "integration")
934933
syscall.Umask(0)
935934
dc, err := getDockerContext()
936935
if err != nil {

test/package_noteardown_test.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
//go:build integration && keepcontainers
1+
//go:build keepcontainers
22

33
package test
44

5-
import "fmt"
6-
75
func teardown(dc *dockerContext, cids ...string) error {
86
return nil
97
}

test/util_test.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package test
2+
3+
import (
4+
"os"
5+
"testing"
6+
)
7+
8+
const (
9+
integrationTestEnvVar = "TEST_INTEGRATION"
10+
)
11+
12+
func IsIntegration() bool {
13+
val, isIntegration := os.LookupEnv(integrationTestEnvVar)
14+
return isIntegration && val != "false" && val != ""
15+
}
16+
17+
func CheckSkipIntegration(t *testing.T, name string) {
18+
if !IsIntegration() {
19+
t.Skipf("Skipping integration test %s, set %s to run", integrationTestEnvVar, name)
20+
}
21+
}

0 commit comments

Comments
 (0)