Skip to content

Commit

Permalink
Remove infer/tests/go.{mod,sum} (#287)
Browse files Browse the repository at this point in the history
This PR just removes a `go.{mod,sum}` and then fixes the newly applied
linter rules (mostly paralleltest). No non-test code is effected.
  • Loading branch information
iwahbe authored Jan 14, 2025
1 parent 7854e52 commit 0ff4563
Show file tree
Hide file tree
Showing 10 changed files with 80 additions and 442 deletions.
40 changes: 22 additions & 18 deletions infer/tests/check_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,29 +48,33 @@ func TestCheckConfig(t *testing.T) {

func TestCheckConfigCustom(t *testing.T) {
t.Parallel()

pString := resource.NewStringProperty
pNumber := resource.NewNumberProperty
type pMap = resource.PropertyMap
type pValue = resource.PropertyValue

test := func(inputs, expected pMap) func(t *testing.T) {
return func(t *testing.T) {
prov := providerWithConfig[*ConfigCustom]()
resp, err := prov.CheckConfig(p.CheckRequest{
Urn: urn("provider", "provider"),
News: inputs,
})
require.NoError(t, err)
test := func(t *testing.T, inputs, expected pMap) {
prov := providerWithConfig[*ConfigCustom]()
resp, err := prov.CheckConfig(p.CheckRequest{
Urn: urn("provider", "provider"),
News: inputs,
})
require.NoError(t, err)

assert.Equal(t, expected, resp.Inputs)
}
assert.Equal(t, expected, resp.Inputs)
}

t.Run("empty", test(nil, pMap{}))
t.Run("unknown", test(
pMap{"unknownField": pString("bar")},
pMap{}))
t.Run("number", test(
pMap{"number": pNumber(42)},
pMap{"number": pNumber(42.5)}))
t.Run("empty", func(t *testing.T) { t.Parallel(); test(t, nil, pMap{}) })
t.Run("unknown", func(t *testing.T) {
t.Parallel()
test(t,
pMap{"unknownField": pString("bar")},
pMap{})
})
t.Run("number", func(t *testing.T) {
t.Parallel()
test(t,
pMap{"number": pNumber(42)},
pMap{"number": pNumber(42.5)})
})
}
19 changes: 10 additions & 9 deletions infer/tests/check_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import (
)

func TestCheckDefaults(t *testing.T) {
t.Parallel()

// Helper bindings for constructing property maps
pInt := func(i int) resource.PropertyValue {
return resource.NewNumberProperty(float64(i))
Expand Down Expand Up @@ -93,8 +95,8 @@ func TestCheckDefaults(t *testing.T) {
}
}

t.Run("empty", against(pMap{}, defaultMap()))
t.Run("required-under-optional", against(pMap{
t.Run("empty", against(pMap{}, defaultMap())) //nolint:paralleltest // against already calls t.Parallel.
t.Run("required-under-optional", against(pMap{ //nolint:paralleltest // against already calls t.Parallel.
"optWithReq": pValue{V: pMap{
"req": pString("user-value"),
}},
Expand All @@ -104,7 +106,7 @@ func TestCheckDefaults(t *testing.T) {
"opt": pString("default-value"),
}}
})))
t.Run("some-values", against(pMap{
t.Run("some-values", against(pMap{ //nolint:paralleltest // against already calls t.Parallel.
"pi": pInt(3),
"nestedPtr": pValue{V: pMap{
"i": pInt(3),
Expand All @@ -117,7 +119,7 @@ func TestCheckDefaults(t *testing.T) {
})
}),
))
t.Run("set-optional-value-as-zero", against(pMap{
t.Run("set-optional-value-as-zero", against(pMap{ //nolint:paralleltest // against already calls t.Parallel.
"pi": pInt(0), // We can set a pointer to its elements zero value.

// We cannot set a element to its zero value, since that looks identical
Expand All @@ -134,9 +136,9 @@ func TestCheckDefaults(t *testing.T) {
array := resource.PropertyKey(arrayName)
t.Run("behind-"+arrayName, against(pMap{
array: pValue{V: []pValue{
pValue{V: pMap{"s": pString("foo")}},
pValue{V: pMap{}},
pValue{V: pMap{"s": pString("bar")}},
{V: pMap{"s": pString("foo")}},
{V: pMap{}},
{V: pMap{"s": pString("bar")}},
}},
},
withDefault(func(m pMap) {
Expand All @@ -153,7 +155,7 @@ func TestCheckDefaults(t *testing.T) {
))
}

for _, mapName := range []string{"mapNested", "mapNestedPtr"} {
for _, mapName := range []string{"mapNested", "mapNestedPtr"} { //nolint:paralleltest
mapName := mapName
mapK := resource.PropertyKey(mapName)
t.Run("behind-"+mapName, against(pMap{
Expand Down Expand Up @@ -187,7 +189,6 @@ func TestCheckDefaultsEnv(t *testing.T) {
pBool := resource.NewBoolProperty
pString := resource.NewStringProperty
type pMap = resource.PropertyMap
type pValue = resource.PropertyValue

t.Setenv("STRING", "str")
t.Setenv("INT", "1")
Expand Down
9 changes: 5 additions & 4 deletions infer/tests/configure_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,11 @@ func TestConfigureCustom(t *testing.T) {
pString := resource.NewStringProperty
pNumber := resource.NewNumberProperty
type pMap = resource.PropertyMap
type pValue = resource.PropertyValue

test := func(inputs, expected pMap) func(t *testing.T) {
return func(t *testing.T) {
t.Parallel()

prov := providerWithConfig[*ConfigCustom]()
err := prov.Configure(p.ConfigureRequest{
Args: inputs,
Expand All @@ -70,13 +71,13 @@ func TestConfigureCustom(t *testing.T) {
}
}

t.Run("empty", test(
t.Run("empty", test( //nolint:paralleltest // test already calls t.Parallel.
nil,
pMap{"config": pString(`{"Number":null,"Squared":0}`)}))
t.Run("unknown", test(
t.Run("unknown", test( //nolint:paralleltest // test already calls t.Parallel.
pMap{"unknownField": pString("bar")},
pMap{"config": pString(`{"Number":null,"Squared":0}`)}))
t.Run("number", test(
t.Run("number", test( //nolint:paralleltest // test already calls t.Parallel.
pMap{"number": pNumber(42)},
pMap{"config": pString(`{"Number":42,"Squared":1764}`)}))
}
15 changes: 15 additions & 0 deletions infer/tests/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ import (
)

func TestCreate(t *testing.T) {
t.Parallel()

t.Run("unwired-preview", func(t *testing.T) {
t.Parallel()
prov := provider()
resp, err := prov.Create(p.CreateRequest{
Urn: urn("Echo", "preview"),
Expand Down Expand Up @@ -57,6 +60,8 @@ func TestCreate(t *testing.T) {
})

t.Run("unwired-up", func(t *testing.T) {
t.Parallel()

prov := provider()
resp, err := prov.Create(p.CreateRequest{
Urn: urn("Echo", "create"),
Expand Down Expand Up @@ -90,6 +95,8 @@ func TestCreate(t *testing.T) {
})

t.Run("unwired-secrets", func(t *testing.T) {
t.Parallel()

prov := provider()
sec := resource.MakeSecret
str := resource.NewStringProperty
Expand Down Expand Up @@ -125,6 +132,8 @@ func TestCreate(t *testing.T) {
})

t.Run("unwired-secrets-mutated-input", func(t *testing.T) {
t.Parallel()

prov := provider()
sec := resource.MakeSecret
num := resource.NewNumberProperty
Expand All @@ -145,6 +154,8 @@ func TestCreate(t *testing.T) {
})

t.Run("wired-secrets", func(t *testing.T) {
t.Parallel()

prov := provider()
c := resource.MakeComputed
s := resource.NewStringProperty
Expand All @@ -167,6 +178,8 @@ func TestCreate(t *testing.T) {
})

t.Run("wired-preview", func(t *testing.T) {
t.Parallel()

prov := provider()
c := resource.MakeComputed
s := resource.NewStringProperty
Expand All @@ -188,6 +201,8 @@ func TestCreate(t *testing.T) {
})

t.Run("wired-up", func(t *testing.T) {
t.Parallel()

prov := provider()
s := resource.NewStringProperty
resp, err := prov.Create(p.CreateRequest{
Expand Down
104 changes: 0 additions & 104 deletions infer/tests/go.mod

This file was deleted.

Loading

0 comments on commit 0ff4563

Please sign in to comment.