Skip to content

Commit

Permalink
Introduce integration test target and cache busting (#137)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sotirios Mantziaris authored Jul 2, 2021
1 parent ec4d5a9 commit 5ab506b
Showing 1 changed file with 25 additions and 9 deletions.
34 changes: 25 additions & 9 deletions targets/test/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,16 @@ import (
"github.com/taxibeat/bake/docker"
)

const (
goCmd = "go"
componentTestTag = "component"
integrationTestTag = "integration"
)

var (
// GoBuildTags used when running all tests.
GoBuildTags = []string{
"component",
"integration",
}
GoBuildTags = []string{componentTestTag, integrationTestTag}

// TestArgs used in test targets.
TestArgs = []string{
"test",
Expand All @@ -40,10 +44,6 @@ var (
CoverExcludeFile = "coverage.txt"
)

const (
goCmd = "go"
)

// Test groups together test related tasks.
type Test mg.Namespace

Expand All @@ -53,9 +53,21 @@ func (Test) Unit() error {
return run(args)
}

// Integration runs unit and integration tests.
func (Test) Integration() error {
args := append(appendCacheBustingArg(TestArgs), getBuildTagFlag([]string{integrationTestTag}), Pkgs)
return run(args)
}

// Component runs unit and component tests.
func (Test) Component() error {
args := append(appendCacheBustingArg(TestArgs), getBuildTagFlag([]string{componentTestTag}), Pkgs)
return run(args)
}

// All runs all tests.
func (Test) All() error {
args := append(TestArgs, getBuildTagFlag(GoBuildTags), Pkgs)
args := append(appendCacheBustingArg(TestArgs), getBuildTagFlag(GoBuildTags), Pkgs)
return run(args)
}

Expand Down Expand Up @@ -91,3 +103,7 @@ func run(args []string) error {
func getBuildTagFlag(buildTags []string) string {
return "-tags=" + strings.Join(buildTags, ",")
}

func appendCacheBustingArg(args []string) []string {
return append(args, "-count=1")
}

0 comments on commit 5ab506b

Please sign in to comment.