Fix variable for container name

This commit is contained in:
Kristoffer Dalby 2022-08-03 11:12:39 +02:00
parent c0846978ed
commit a2d1b88b80
3 changed files with 31 additions and 11 deletions

View File

@ -19,6 +19,10 @@ import (
"github.com/stretchr/testify/suite" "github.com/stretchr/testify/suite"
) )
const (
headscaleCLIContainerName = "headscale-cli"
)
type IntegrationCLITestSuite struct { type IntegrationCLITestSuite struct {
suite.Suite suite.Suite
stats *suite.SuiteInformation stats *suite.SuiteInformation
@ -65,7 +69,7 @@ func (s *IntegrationCLITestSuite) SetupTest() {
} }
headscaleOptions := &dockertest.RunOptions{ headscaleOptions := &dockertest.RunOptions{
Name: "headscale-cli", Name: headscaleCLIContainerName,
Mounts: []string{ Mounts: []string{
fmt.Sprintf("%s/integration_test/etc:/etc/headscale", currentPath), fmt.Sprintf("%s/integration_test/etc:/etc/headscale", currentPath),
}, },
@ -74,9 +78,15 @@ func (s *IntegrationCLITestSuite) SetupTest() {
Platform: platform, Platform: platform,
} }
err = s.pool.RemoveContainerByName(headscaleHostname) err = s.pool.RemoveContainerByName(headscaleCLIContainerName)
if err != nil { if err != nil {
s.FailNow(fmt.Sprintf("Could not remove existing container before building test: %s", err), "") s.FailNow(
fmt.Sprintf(
"Could not remove existing container before building test: %s",
err,
),
"",
)
} }
fmt.Println("Creating headscale container") fmt.Println("Creating headscale container")

View File

@ -29,9 +29,9 @@ import (
) )
const ( const (
headscaleHostname = "headscale-derp" headscaleDerpContainerName = "headscale-derp"
namespaceName = "derpnamespace" namespaceName = "derpnamespace"
totalContainers = 3 totalContainers = 3
) )
type IntegrationDERPTestSuite struct { type IntegrationDERPTestSuite struct {
@ -119,7 +119,7 @@ func (s *IntegrationDERPTestSuite) SetupSuite() {
} }
headscaleOptions := &dockertest.RunOptions{ headscaleOptions := &dockertest.RunOptions{
Name: headscaleHostname, Name: headscaleDerpContainerName,
Mounts: []string{ Mounts: []string{
fmt.Sprintf( fmt.Sprintf(
"%s/integration_test/etc_embedded_derp:/etc/headscale", "%s/integration_test/etc_embedded_derp:/etc/headscale",
@ -135,9 +135,15 @@ func (s *IntegrationDERPTestSuite) SetupSuite() {
Platform: platform, Platform: platform,
} }
err = s.pool.RemoveContainerByName(headscaleHostname) err = s.pool.RemoveContainerByName(headscaleDerpContainerName)
if err != nil { if err != nil {
s.FailNow(fmt.Sprintf("Could not remove existing container before building test: %s", err), "") s.FailNow(
fmt.Sprintf(
"Could not remove existing container before building test: %s",
err,
),
"",
)
} }
log.Println("Creating headscale container") log.Println("Creating headscale container")

View File

@ -1,4 +1,4 @@
//go:build integration s/go:build integration
// +build integration // +build integration
package headscale package headscale
@ -30,6 +30,10 @@ import (
"tailscale.com/ipn/ipnstate" "tailscale.com/ipn/ipnstate"
) )
const (
headscaleContainerName = "headscale"
)
type IntegrationTestSuite struct { type IntegrationTestSuite struct {
suite.Suite suite.Suite
stats *suite.SuiteInformation stats *suite.SuiteInformation
@ -252,7 +256,7 @@ func (s *IntegrationTestSuite) SetupSuite() {
Platform: platform, Platform: platform,
} }
err = s.pool.RemoveContainerByName(headscaleHostname) err = s.pool.RemoveContainerByName(headscaleContainerName)
if err != nil { if err != nil {
s.FailNow(fmt.Sprintf("Could not remove existing container before building test: %s", err), "") s.FailNow(fmt.Sprintf("Could not remove existing container before building test: %s", err), "")
} }