From 8ee35c9c226cfe6ed8ae8b46bc6be3a96810a223 Mon Sep 17 00:00:00 2001 From: Kristoffer Dalby Date: Fri, 7 Oct 2022 22:10:33 +0200 Subject: [PATCH] Stuff Signed-off-by: Kristoffer Dalby --- integration_cli_test.go | 12 ++++++------ integration_common_test.go | 1 + integration_embedded_derp_test.go | 3 ++- integration_general_test.go | 8 ++++---- integration_oidc_test.go | 2 +- 5 files changed, 14 insertions(+), 12 deletions(-) diff --git a/integration_cli_test.go b/integration_cli_test.go index cc9d33b..0f5d69a 100644 --- a/integration_cli_test.go +++ b/integration_cli_test.go @@ -43,11 +43,11 @@ func (s *IntegrationCLITestSuite) SetupTest() { s.FailNow(fmt.Sprintf("Could not connect to docker: %s", err), "") } - if pnetwork, err := s.pool.CreateNetwork("headscale-test"); err == nil { - s.network = *pnetwork - } else { - s.FailNow(fmt.Sprintf("Could not create network: %s", err), "") + network, err := GetFirstOrCreateNetwork(&s.pool, headscaleNetwork) + if err != nil { + s.FailNow(fmt.Sprintf("Failed to create or get network: %s", err), "") } + s.network = network headscaleBuildOptions := &dockertest.BuildOptions{ Dockerfile: "Dockerfile", @@ -64,12 +64,12 @@ func (s *IntegrationCLITestSuite) SetupTest() { Mounts: []string{ fmt.Sprintf("%s/integration_test/etc:/etc/headscale", currentPath), }, + Cmd: []string{"headscale", "serve"}, + Networks: []*dockertest.Network{&s.network}, ExposedPorts: []string{"8080/tcp"}, PortBindings: map[docker.Port][]docker.PortBinding{ "8080/tcp": {{HostPort: "8080"}}, }, - Networks: []*dockertest.Network{&s.network}, - Cmd: []string{"headscale", "serve"}, } err = s.pool.RemoveContainerByName(headscaleHostname) diff --git a/integration_common_test.go b/integration_common_test.go index 1d69972..f3c3923 100644 --- a/integration_common_test.go +++ b/integration_common_test.go @@ -19,6 +19,7 @@ import ( ) const ( + headscaleNetwork = "headscale-test" headscaleHostname = "headscale" DOCKER_EXECUTE_TIMEOUT = 10 * time.Second ) diff --git a/integration_embedded_derp_test.go b/integration_embedded_derp_test.go index 421e01d..c83f610 100644 --- a/integration_embedded_derp_test.go +++ b/integration_embedded_derp_test.go @@ -95,7 +95,7 @@ func (s *IntegrationDERPTestSuite) SetupSuite() { s.FailNow(fmt.Sprintf("Could not connect to docker: %s", err), "") } - network, err := GetFirstOrCreateNetwork(&s.pool, "headscale-test") + network, err := GetFirstOrCreateNetwork(&s.pool, headscaleNetwork) if err != nil { s.FailNow(fmt.Sprintf("Failed to create or get network: %s", err), "") } @@ -120,6 +120,7 @@ func (s *IntegrationDERPTestSuite) SetupSuite() { } headscaleOptions := &dockertest.RunOptions{ + Name: headscaleDerpHostname, Mounts: []string{ fmt.Sprintf( diff --git a/integration_general_test.go b/integration_general_test.go index 500247d..5b5abf0 100644 --- a/integration_general_test.go +++ b/integration_general_test.go @@ -230,11 +230,11 @@ func (s *IntegrationTestSuite) SetupSuite() { s.FailNow(fmt.Sprintf("Could not connect to docker: %s", err), "") } - if pnetwork, err := s.pool.CreateNetwork("headscale-test"); err == nil { - s.network = *pnetwork - } else { - s.FailNow(fmt.Sprintf("Could not create network: %s", err), "") + network, err := GetFirstOrCreateNetwork(&s.pool, headscaleNetwork) + if err != nil { + s.FailNow(fmt.Sprintf("Failed to create or get network: %s", err), "") } + s.network = network headscaleBuildOptions := &dockertest.BuildOptions{ Dockerfile: "Dockerfile", diff --git a/integration_oidc_test.go b/integration_oidc_test.go index 27c1e7b..ba0b00f 100644 --- a/integration_oidc_test.go +++ b/integration_oidc_test.go @@ -96,7 +96,7 @@ func (s *IntegrationOIDCTestSuite) SetupSuite() { s.FailNow(fmt.Sprintf("Could not connect to docker: %s", err), "") } - network, err := GetFirstOrCreateNetwork(&s.pool, "headscale-test") + network, err := GetFirstOrCreateNetwork(&s.pool, headscaleNetwork) if err != nil { s.FailNow(fmt.Sprintf("Failed to create or get network: %s", err), "") }