cli/compose: remove redundant reflection from tests

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2022-09-29 15:34:20 +02:00
parent c39dfc3801
commit a9ccb6552d
No known key found for this signature in database
GPG Key ID: 76698F39D527CE8C
2 changed files with 9 additions and 11 deletions

View File

@ -3,7 +3,6 @@ package loader
import ( import (
"bytes" "bytes"
"os" "os"
"reflect"
"sort" "sort"
"testing" "testing"
"time" "time"
@ -792,8 +791,10 @@ services:
// Default behavior keeps the `env_file` entries // Default behavior keeps the `env_file` entries
configWithEnvFiles, err := Load(configDetails) configWithEnvFiles, err := Load(configDetails)
assert.NilError(t, err) assert.NilError(t, err)
assert.DeepEqual(t, configWithEnvFiles.Services[0].EnvFile, types.StringList{"example1.env", assert.DeepEqual(t, configWithEnvFiles.Services[0].EnvFile, types.StringList{
"example2.env"}) "example1.env",
"example2.env",
})
assert.DeepEqual(t, configWithEnvFiles.Services[0].Environment, expectedEnvironmentMap) assert.DeepEqual(t, configWithEnvFiles.Services[0].Environment, expectedEnvironmentMap)
// Custom behavior removes the `env_file` entries // Custom behavior removes the `env_file` entries
@ -862,7 +863,7 @@ services:
service: foo service: foo
`) `)
assert.ErrorType(t, err, reflect.TypeOf(&ForbiddenPropertiesError{})) assert.ErrorType(t, err, &ForbiddenPropertiesError{})
props := err.(*ForbiddenPropertiesError).Properties props := err.(*ForbiddenPropertiesError).Properties
assert.Check(t, is.Len(props, 2)) assert.Check(t, is.Len(props, 2))
@ -1343,7 +1344,6 @@ func TestLoadVolumesWarnOnDeprecatedExternalNameVersion34(t *testing.T) {
} }
assert.Check(t, is.DeepEqual(expected, volumes)) assert.Check(t, is.DeepEqual(expected, volumes))
assert.Check(t, is.Contains(buf.String(), "volume.external.name is deprecated")) assert.Check(t, is.Contains(buf.String(), "volume.external.name is deprecated"))
} }
func patchLogrus() (*bytes.Buffer, func()) { func patchLogrus() (*bytes.Buffer, func()) {
@ -1483,7 +1483,6 @@ func TestLoadNetworksWarnOnDeprecatedExternalNameVersion35(t *testing.T) {
} }
assert.Check(t, is.DeepEqual(expected, networks)) assert.Check(t, is.DeepEqual(expected, networks))
assert.Check(t, is.Contains(buf.String(), "network.external.name is deprecated")) assert.Check(t, is.Contains(buf.String(), "network.external.name is deprecated"))
} }
func TestLoadNetworksWarnOnDeprecatedExternalNameVersion34(t *testing.T) { func TestLoadNetworksWarnOnDeprecatedExternalNameVersion34(t *testing.T) {
@ -1564,7 +1563,7 @@ func TestLoadInit(t *testing.T) {
booleanTrue := true booleanTrue := true
booleanFalse := false booleanFalse := false
var testcases = []struct { testcases := []struct {
doc string doc string
yaml string yaml string
init *bool init *bool
@ -1651,7 +1650,7 @@ services:
} }
func TestTransform(t *testing.T) { func TestTransform(t *testing.T) {
var source = []interface{}{ source := []interface{}{
"80-82:8080-8082", "80-82:8080-8082",
"90-92:8090-8092/udp", "90-92:8090-8092/udp",
"85:8500", "85:8500",

View File

@ -2,7 +2,6 @@ package template
import ( import (
"fmt" "fmt"
"reflect"
"testing" "testing"
"gotest.tools/v3/assert" "gotest.tools/v3/assert"
@ -125,8 +124,8 @@ func TestMandatoryVariableErrors(t *testing.T) {
for _, tc := range testCases { for _, tc := range testCases {
_, err := Substitute(tc.template, defaultMapping) _, err := Substitute(tc.template, defaultMapping)
assert.ErrorContains(t, err, tc.expectedError) assert.Check(t, is.ErrorContains(err, tc.expectedError))
assert.ErrorType(t, err, reflect.TypeOf(&InvalidTemplateError{})) assert.Check(t, is.ErrorType(err, &InvalidTemplateError{}))
} }
} }