mirror of
https://github.com/juanfont/headscale.git
synced 2024-11-30 13:35:23 +00:00
Fail tests instead of fatal
Currently we exit the program if the setup does not work, this can cause is to leave containers and other resources behind since we dont run TearDown. This change will just fail the test if we cant set up, which should mean that the TearDown runs aswell.
This commit is contained in:
parent
911c5bddce
commit
8cae4f80d7
@ -92,14 +92,14 @@ func (s *IntegrationDERPTestSuite) SetupSuite() {
|
|||||||
if ppool, err := dockertest.NewPool(""); err == nil {
|
if ppool, err := dockertest.NewPool(""); err == nil {
|
||||||
s.pool = *ppool
|
s.pool = *ppool
|
||||||
} else {
|
} else {
|
||||||
log.Fatalf("Could not connect to docker: %s", err)
|
s.FailNow(fmt.Sprintf("Could not connect to docker: %s", err), "")
|
||||||
}
|
}
|
||||||
|
|
||||||
for i := 0; i < totalContainers; i++ {
|
for i := 0; i < totalContainers; i++ {
|
||||||
if pnetwork, err := s.pool.CreateNetwork(fmt.Sprintf("headscale-derp-%d", i)); err == nil {
|
if pnetwork, err := s.pool.CreateNetwork(fmt.Sprintf("headscale-derp-%d", i)); err == nil {
|
||||||
s.networks[i] = *pnetwork
|
s.networks[i] = *pnetwork
|
||||||
} else {
|
} else {
|
||||||
log.Fatalf("Could not create network: %s", err)
|
s.FailNow(fmt.Sprintf("Could not create network: %s", err), "")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,7 +110,7 @@ func (s *IntegrationDERPTestSuite) SetupSuite() {
|
|||||||
|
|
||||||
currentPath, err := os.Getwd()
|
currentPath, err := os.Getwd()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("Could not determine current path: %s", err)
|
s.FailNow(fmt.Sprintf("Could not determine current path: %s", err), "")
|
||||||
}
|
}
|
||||||
|
|
||||||
headscaleOptions := &dockertest.RunOptions{
|
headscaleOptions := &dockertest.RunOptions{
|
||||||
@ -133,7 +133,7 @@ func (s *IntegrationDERPTestSuite) SetupSuite() {
|
|||||||
if pheadscale, err := s.pool.BuildAndRunWithBuildOptions(headscaleBuildOptions, headscaleOptions, DockerRestartPolicy); err == nil {
|
if pheadscale, err := s.pool.BuildAndRunWithBuildOptions(headscaleBuildOptions, headscaleOptions, DockerRestartPolicy); err == nil {
|
||||||
s.headscale = *pheadscale
|
s.headscale = *pheadscale
|
||||||
} else {
|
} else {
|
||||||
log.Fatalf("Could not start headscale container: %s", err)
|
s.FailNow(fmt.Sprintf("Could not start headscale container: %s", err), "")
|
||||||
}
|
}
|
||||||
log.Println("Created headscale container to test DERP")
|
log.Println("Created headscale container to test DERP")
|
||||||
|
|
||||||
|
@ -218,13 +218,13 @@ func (s *IntegrationTestSuite) SetupSuite() {
|
|||||||
if ppool, err := dockertest.NewPool(""); err == nil {
|
if ppool, err := dockertest.NewPool(""); err == nil {
|
||||||
s.pool = *ppool
|
s.pool = *ppool
|
||||||
} else {
|
} else {
|
||||||
log.Fatalf("Could not connect to docker: %s", err)
|
s.FailNow(fmt.Sprintf("Could not connect to docker: %s", err), "")
|
||||||
}
|
}
|
||||||
|
|
||||||
if pnetwork, err := s.pool.CreateNetwork("headscale-test"); err == nil {
|
if pnetwork, err := s.pool.CreateNetwork("headscale-test"); err == nil {
|
||||||
s.network = *pnetwork
|
s.network = *pnetwork
|
||||||
} else {
|
} else {
|
||||||
log.Fatalf("Could not create network: %s", err)
|
s.FailNow(fmt.Sprintf("Could not create network: %s", err), "")
|
||||||
}
|
}
|
||||||
|
|
||||||
headscaleBuildOptions := &dockertest.BuildOptions{
|
headscaleBuildOptions := &dockertest.BuildOptions{
|
||||||
@ -234,7 +234,7 @@ func (s *IntegrationTestSuite) SetupSuite() {
|
|||||||
|
|
||||||
currentPath, err := os.Getwd()
|
currentPath, err := os.Getwd()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("Could not determine current path: %s", err)
|
s.FailNow(fmt.Sprintf("Could not determine current path: %s", err), "")
|
||||||
}
|
}
|
||||||
|
|
||||||
headscaleOptions := &dockertest.RunOptions{
|
headscaleOptions := &dockertest.RunOptions{
|
||||||
@ -250,7 +250,7 @@ func (s *IntegrationTestSuite) SetupSuite() {
|
|||||||
if pheadscale, err := s.pool.BuildAndRunWithBuildOptions(headscaleBuildOptions, headscaleOptions, DockerRestartPolicy); err == nil {
|
if pheadscale, err := s.pool.BuildAndRunWithBuildOptions(headscaleBuildOptions, headscaleOptions, DockerRestartPolicy); err == nil {
|
||||||
s.headscale = *pheadscale
|
s.headscale = *pheadscale
|
||||||
} else {
|
} else {
|
||||||
log.Fatalf("Could not start headscale container: %s", err)
|
s.FailNow(fmt.Sprintf("Could not start headscale container: %s", err), "")
|
||||||
}
|
}
|
||||||
log.Println("Created headscale container")
|
log.Println("Created headscale container")
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user