Skip to content

Commit

Permalink
Skip integration tests on short or lack of docker
Browse files Browse the repository at this point in the history
Signed-off-by: Kristoffer Dalby <[email protected]>
  • Loading branch information
kradalby committed Oct 18, 2022
1 parent a9c3b14 commit eda4321
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
14 changes: 13 additions & 1 deletion integration/dockertestutil/config.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
package dockertestutil

import "github.com/ory/dockertest/v3/docker"
import (
"os"

"github.com/ory/dockertest/v3/docker"
)

func IsRunningInContainer() bool {
if _, err := os.Stat("/.dockerenv"); err != nil {
return false
}

return true
}

func DockerRestartPolicy(config *docker.HostConfig) {
// set AutoRemove to true so that stopped container goes away by itself on error *immediately*.
Expand Down
18 changes: 18 additions & 0 deletions integration/scenario_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,24 @@ package integration
import (
"testing"

"github.com/juanfont/headscale/integration/dockertestutil"
"github.com/juanfont/headscale/integration/tsic"
)

func IntegrationSkip(t *testing.T) {
t.Helper()

if !dockertestutil.IsRunningInContainer() {
t.Skip("not running in docker, skipping")
}

if testing.Short() {
t.Skip("skipping integration tests due to short flag")
}
}

func TestHeadscale(t *testing.T) {
IntegrationSkip(t)
var err error

scenario, err := NewScenario()
Expand Down Expand Up @@ -52,6 +66,8 @@ func TestHeadscale(t *testing.T) {
}

func TestCreateTailscale(t *testing.T) {
IntegrationSkip(t)

var scenario *Scenario
var err error

Expand Down Expand Up @@ -84,6 +100,8 @@ func TestCreateTailscale(t *testing.T) {
}

func TestTailscaleNodesJoiningHeadcale(t *testing.T) {
IntegrationSkip(t)

var err error

namespace := "join-node-test"
Expand Down

0 comments on commit eda4321

Please sign in to comment.