Skip to content

Commit

Permalink
chore: use require.Len instead of assert.Len
Browse files Browse the repository at this point in the history
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
  • Loading branch information
mmorel-35 committed Oct 29, 2024
1 parent 2cec4a1 commit 8ccc448
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 32 deletions.
2 changes: 1 addition & 1 deletion lifecycle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -781,7 +781,7 @@ func TestCombineLifecycleHooks(t *testing.T) {

// There are 5 lifecycles (create, start, ready, stop, terminate),
// but ready has only half of the hooks (it only has post), so we have 90 hooks in total.
assert.Len(t, prints, 90)
require.Len(t, prints, 90)

// The order of the hooks is:
// - pre-X hooks: first default (2*2), then user-defined (3*2)
Expand Down
2 changes: 1 addition & 1 deletion modulegen/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ func assertMkdocsNavItems(t *testing.T, module context.TestcontainersModule, ori
expectedEntries = originalConfig.Nav[3].Modules
}

assert.Len(t, navItems, len(expectedEntries)+1)
require.Len(t, navItems, len(expectedEntries)+1)

// the module should be in the nav
found := false
Expand Down
2 changes: 1 addition & 1 deletion modulegen/mkdocs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func TestNavItems(t *testing.T) {
require.NoError(t, err)

// we have to remove the index.md file from the examples docs
assert.Len(t, examples, len(examplesDocs)-1)
require.Len(t, examples, len(examplesDocs)-1)

// all example modules exist in the documentation
for _, example := range examples {
Expand Down
24 changes: 12 additions & 12 deletions modules/compose/compose_api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func TestDockerComposeAPIStrategyForInvalidService(t *testing.T) {

serviceNames := compose.Services()

assert.Len(t, serviceNames, 1)
require.Len(t, serviceNames, 1)
assert.Contains(t, serviceNames, "api-nginx")
}

Expand Down Expand Up @@ -102,7 +102,7 @@ func TestDockerComposeAPIWithRunServices(t *testing.T) {
_, err = compose.ServiceContainer(context.Background(), "api-mysql")
require.Error(t, err, "Make sure there is no mysql container")

assert.Len(t, serviceNames, 1)
require.Len(t, serviceNames, 1)
assert.Contains(t, serviceNames, "api-nginx")
}

Expand Down Expand Up @@ -304,7 +304,7 @@ func TestDockerComposeAPIWithWaitForService(t *testing.T) {

serviceNames := compose.Services()

assert.Len(t, serviceNames, 1)
require.Len(t, serviceNames, 1)
assert.Contains(t, serviceNames, "api-nginx")
}

Expand All @@ -327,7 +327,7 @@ func TestDockerComposeAPIWithWaitHTTPStrategy(t *testing.T) {

serviceNames := compose.Services()

assert.Len(t, serviceNames, 1)
require.Len(t, serviceNames, 1)
assert.Contains(t, serviceNames, "api-nginx")
}

Expand All @@ -350,7 +350,7 @@ func TestDockerComposeAPIWithContainerName(t *testing.T) {

serviceNames := compose.Services()

assert.Len(t, serviceNames, 1)
require.Len(t, serviceNames, 1)
assert.Contains(t, serviceNames, "api-nginx")
}

Expand All @@ -370,7 +370,7 @@ func TestDockerComposeAPIWithWaitStrategy_NoExposedPorts(t *testing.T) {

serviceNames := compose.Services()

assert.Len(t, serviceNames, 1)
require.Len(t, serviceNames, 1)
assert.Contains(t, serviceNames, "api-nginx")
}

Expand Down Expand Up @@ -417,7 +417,7 @@ func TestDockerComposeAPIWithFailedStrategy(t *testing.T) {

serviceNames := compose.Services()

assert.Len(t, serviceNames, 1)
require.Len(t, serviceNames, 1)
assert.Contains(t, serviceNames, "api-nginx")
}

Expand Down Expand Up @@ -469,7 +469,7 @@ services:

serviceNames := compose.Services()

assert.Len(t, serviceNames, 1)
require.Len(t, serviceNames, 1)
assert.Contains(t, serviceNames, "api-nginx")

require.NoError(t, compose.Down(context.Background(), RemoveOrphans(true), RemoveVolumes(true), RemoveImagesLocal), "compose.Down()")
Expand Down Expand Up @@ -513,7 +513,7 @@ services:

serviceNames := compose.Services()

assert.Len(t, serviceNames, 2)
require.Len(t, serviceNames, 2)
assert.Contains(t, serviceNames, "api-nginx")
assert.Contains(t, serviceNames, "api-postgres")

Expand Down Expand Up @@ -546,7 +546,7 @@ func TestDockerComposeAPIWithEnvironment(t *testing.T) {

serviceNames := compose.Services()

assert.Len(t, serviceNames, 1)
require.Len(t, serviceNames, 1)
assert.Contains(t, serviceNames, "api-nginx")

present := map[string]string{
Expand Down Expand Up @@ -583,7 +583,7 @@ func TestDockerComposeAPIWithMultipleComposeFiles(t *testing.T) {

serviceNames := compose.Services()

assert.Len(t, serviceNames, 3)
require.Len(t, serviceNames, 3)
assert.Contains(t, serviceNames, "api-nginx")
assert.Contains(t, serviceNames, "api-mysql")
assert.Contains(t, serviceNames, "api-postgres")
Expand Down Expand Up @@ -684,7 +684,7 @@ func TestDockerComposeApiWithWaitForShortLifespanService(t *testing.T) {

services := compose.Services()

assert.Len(t, services, 2)
require.Len(t, services, 2)
assert.Contains(t, services, "falafel")
assert.Contains(t, services, "tzatziki")
}
Expand Down
24 changes: 12 additions & 12 deletions modules/compose/compose_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ func TestLocalDockerComposeStrategyForInvalidService(t *testing.T) {
Invoke()
require.Error(t, err.Error, "Expected error to be thrown because service with wait strategy is not running")

assert.Len(t, compose.Services, 1)
require.Len(t, compose.Services, 1)
assert.Contains(t, compose.Services, "local-nginx")
}

Expand All @@ -157,7 +157,7 @@ func TestLocalDockerComposeWithWaitLogStrategy(t *testing.T) {
Invoke()
checkIfError(t, err)

assert.Len(t, compose.Services, 2)
require.Len(t, compose.Services, 2)
assert.Contains(t, compose.Services, "local-nginx")
assert.Contains(t, compose.Services, "local-mysql")
}
Expand All @@ -183,7 +183,7 @@ func TestLocalDockerComposeWithWaitForService(t *testing.T) {
Invoke()
checkIfError(t, err)

assert.Len(t, compose.Services, 1)
require.Len(t, compose.Services, 1)
assert.Contains(t, compose.Services, "local-nginx")
}

Expand All @@ -207,7 +207,7 @@ func TestLocalDockerComposeWithWaitForShortLifespanService(t *testing.T) {
Invoke()
checkIfError(t, err)

assert.Len(t, compose.Services, 2)
require.Len(t, compose.Services, 2)
assert.Contains(t, compose.Services, "falafel")
assert.Contains(t, compose.Services, "tzatziki")
}
Expand All @@ -233,7 +233,7 @@ func TestLocalDockerComposeWithWaitHTTPStrategy(t *testing.T) {
Invoke()
checkIfError(t, err)

assert.Len(t, compose.Services, 1)
require.Len(t, compose.Services, 1)
assert.Contains(t, compose.Services, "local-nginx")
}

Expand All @@ -258,7 +258,7 @@ func TestLocalDockerComposeWithContainerName(t *testing.T) {
Invoke()
checkIfError(t, err)

assert.Len(t, compose.Services, 1)
require.Len(t, compose.Services, 1)
assert.Contains(t, compose.Services, "local-nginx")
}

Expand All @@ -280,7 +280,7 @@ func TestLocalDockerComposeWithWaitStrategy_NoExposedPorts(t *testing.T) {
Invoke()
checkIfError(t, err)

assert.Len(t, compose.Services, 1)
require.Len(t, compose.Services, 1)
assert.Contains(t, compose.Services, "local-nginx")
}

Expand All @@ -303,7 +303,7 @@ func TestLocalDockerComposeWithMultipleWaitStrategies(t *testing.T) {
Invoke()
checkIfError(t, err)

assert.Len(t, compose.Services, 2)
require.Len(t, compose.Services, 2)
assert.Contains(t, compose.Services, "local-nginx")
assert.Contains(t, compose.Services, "local-mysql")
}
Expand Down Expand Up @@ -331,7 +331,7 @@ func TestLocalDockerComposeWithFailedStrategy(t *testing.T) {
// A specific error message matcher is not asserted since the docker library can change the return message, breaking this test
require.Error(t, err.Error, "Expected error to be thrown because of a wrong suplied wait strategy")

assert.Len(t, compose.Services, 1)
require.Len(t, compose.Services, 1)
assert.Contains(t, compose.Services, "local-nginx")
}

Expand All @@ -352,7 +352,7 @@ func TestLocalDockerComposeComplex(t *testing.T) {
Invoke()
checkIfError(t, err)

assert.Len(t, compose.Services, 2)
require.Len(t, compose.Services, 2)
assert.Contains(t, compose.Services, "local-nginx")
assert.Contains(t, compose.Services, "local-mysql")
}
Expand All @@ -377,7 +377,7 @@ func TestLocalDockerComposeWithEnvironment(t *testing.T) {
Invoke()
checkIfError(t, err)

assert.Len(t, compose.Services, 1)
require.Len(t, compose.Services, 1)
assert.Contains(t, compose.Services, "local-nginx")

present := map[string]string{
Expand Down Expand Up @@ -413,7 +413,7 @@ func TestLocalDockerComposeWithMultipleComposeFiles(t *testing.T) {
Invoke()
checkIfError(t, err)

assert.Len(t, compose.Services, 3)
require.Len(t, compose.Services, 3)
assert.Contains(t, compose.Services, "local-nginx")
assert.Contains(t, compose.Services, "local-mysql")
assert.Contains(t, compose.Services, "local-postgres")
Expand Down
4 changes: 2 additions & 2 deletions modules/localstack/v1/s3_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func TestS3(t *testing.T) {
require.NotNil(t, output)

buckets := output.Buckets
assert.Len(t, buckets, 1)
require.Len(t, buckets, 1)
assert.Equal(t, bucketName, *buckets[0].Name)
})

Expand All @@ -117,7 +117,7 @@ func TestS3(t *testing.T) {

objects := output.Contents

assert.Len(t, objects, 1)
require.Len(t, objects, 1)
assert.Equal(t, s3Key1, *objects[0].Key)
assert.Equal(t, int64(len(body1)), *objects[0].Size)
})
Expand Down
4 changes: 2 additions & 2 deletions modules/localstack/v2/s3_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func TestS3(t *testing.T) {
require.NotNil(t, output)

buckets := output.Buckets
assert.Len(t, buckets, 1)
require.Len(t, buckets, 1)
assert.Equal(t, bucketName, *buckets[0].Name)
})

Expand All @@ -123,7 +123,7 @@ func TestS3(t *testing.T) {

objects := output.Contents

assert.Len(t, objects, 1)
require.Len(t, objects, 1)
assert.Equal(t, s3Key1, *objects[0].Key)
assert.Equal(t, aws.Int64(int64(len(body1))), objects[0].Size)
})
Expand Down
2 changes: 1 addition & 1 deletion options_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func TestOverrideContainerRequest(t *testing.T) {

// toBeMergedRequest should not be changed
assert.Equal(t, "", toBeMergedRequest.Env["BAR"])
assert.Len(t, toBeMergedRequest.ExposedPorts, 1)
require.Len(t, toBeMergedRequest.ExposedPorts, 1)
assert.Equal(t, "67890/tcp", toBeMergedRequest.ExposedPorts[0])

// req should be merged with toBeMergedRequest
Expand Down

0 comments on commit 8ccc448

Please sign in to comment.