Skip to content

Commit 27ae069

Browse files
fix: rename helper structs to use more specific names
1 parent 42d5870 commit 27ae069

File tree

3 files changed

+33
-34
lines changed

3 files changed

+33
-34
lines changed

kustomize/commands/edit/remove/removeresource_test.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,18 @@ import (
1111
)
1212

1313
func TestRemoveResources(t *testing.T) {
14-
testCases := []testutils_test.Case{
14+
testCases := []testutils_test.RemoveTestCase{
1515
{
1616
Description: "remove resources",
17-
Given: testutils_test.Given{
17+
Given: testutils_test.RemoveTestGivenValues{
1818
Items: []string{
1919
"resource1.yaml",
2020
"resource2.yaml",
2121
"resource3.yaml",
2222
},
2323
RemoveArgs: []string{"resource1.yaml"},
2424
},
25-
Expected: testutils_test.Expected{
25+
Expected: testutils_test.RemoveTestExpectedValues{
2626
Items: []string{
2727
"resource2.yaml",
2828
"resource3.yaml",
@@ -34,7 +34,7 @@ func TestRemoveResources(t *testing.T) {
3434
},
3535
{
3636
Description: "remove resource with pattern",
37-
Given: testutils_test.Given{
37+
Given: testutils_test.RemoveTestGivenValues{
3838
Items: []string{
3939
"foo/resource1.yaml",
4040
"foo/resource2.yaml",
@@ -43,7 +43,7 @@ func TestRemoveResources(t *testing.T) {
4343
},
4444
RemoveArgs: []string{"foo/resource*.yaml"},
4545
},
46-
Expected: testutils_test.Expected{
46+
Expected: testutils_test.RemoveTestExpectedValues{
4747
Items: []string{
4848
"do/not/deleteme/please.yaml",
4949
},
@@ -56,15 +56,15 @@ func TestRemoveResources(t *testing.T) {
5656
},
5757
{
5858
Description: "nothing found to remove",
59-
Given: testutils_test.Given{
59+
Given: testutils_test.RemoveTestGivenValues{
6060
Items: []string{
6161
"resource1.yaml",
6262
"resource2.yaml",
6363
"resource3.yaml",
6464
},
6565
RemoveArgs: []string{"foo"},
6666
},
67-
Expected: testutils_test.Expected{
67+
Expected: testutils_test.RemoveTestExpectedValues{
6868
Items: []string{
6969
"resource2.yaml",
7070
"resource3.yaml",
@@ -74,14 +74,14 @@ func TestRemoveResources(t *testing.T) {
7474
},
7575
{
7676
Description: "no arguments",
77-
Given: testutils_test.Given{},
78-
Expected: testutils_test.Expected{
77+
Given: testutils_test.RemoveTestGivenValues{},
78+
Expected: testutils_test.RemoveTestExpectedValues{
7979
Err: errors.New("must specify a resource file"),
8080
},
8181
},
8282
{
8383
Description: "remove with multiple pattern arguments",
84-
Given: testutils_test.Given{
84+
Given: testutils_test.RemoveTestGivenValues{
8585
Items: []string{
8686
"foo/foo.yaml",
8787
"bar/bar.yaml",
@@ -94,7 +94,7 @@ func TestRemoveResources(t *testing.T) {
9494
"res*.yaml",
9595
},
9696
},
97-
Expected: testutils_test.Expected{
97+
Expected: testutils_test.RemoveTestExpectedValues{
9898
Items: []string{
9999
"do/not/deleteme/please.yaml",
100100
},

kustomize/commands/edit/remove/removetransformer_test.go

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,22 @@ import (
77
"testing"
88

99
testutils_test "sigs.k8s.io/kustomize/kustomize/v5/commands/internal/testutils"
10-
1110
"sigs.k8s.io/kustomize/kyaml/errors"
1211
)
1312

1413
func TestRemoveTransformer(t *testing.T) {
15-
testCases := []testutils_test.Case{
14+
testCases := []testutils_test.RemoveTestCase{
1615
{
1716
Description: "remove transformers",
18-
Given: testutils_test.Given{
17+
Given: testutils_test.RemoveTestGivenValues{
1918
Items: []string{
2019
"transformer1.yaml",
2120
"transformer2.yaml",
2221
"transformer3.yaml",
2322
},
2423
RemoveArgs: []string{"transformer1.yaml"},
2524
},
26-
Expected: testutils_test.Expected{
25+
Expected: testutils_test.RemoveTestExpectedValues{
2726
Items: []string{
2827
"transformer2.yaml",
2928
"transformer3.yaml",
@@ -35,7 +34,7 @@ func TestRemoveTransformer(t *testing.T) {
3534
},
3635
{
3736
Description: "remove transformer with pattern",
38-
Given: testutils_test.Given{
37+
Given: testutils_test.RemoveTestGivenValues{
3938
Items: []string{
4039
"foo/transformer1.yaml",
4140
"foo/transformer2.yaml",
@@ -44,7 +43,7 @@ func TestRemoveTransformer(t *testing.T) {
4443
},
4544
RemoveArgs: []string{"foo/transformer*.yaml"},
4645
},
47-
Expected: testutils_test.Expected{
46+
Expected: testutils_test.RemoveTestExpectedValues{
4847
Items: []string{
4948
"do/not/deleteme/please.yaml",
5049
},
@@ -57,15 +56,15 @@ func TestRemoveTransformer(t *testing.T) {
5756
},
5857
{
5958
Description: "nothing found to remove",
60-
Given: testutils_test.Given{
59+
Given: testutils_test.RemoveTestGivenValues{
6160
Items: []string{
6261
"transformer1.yaml",
6362
"transformer2.yaml",
6463
"transformer3.yaml",
6564
},
6665
RemoveArgs: []string{"foo"},
6766
},
68-
Expected: testutils_test.Expected{
67+
Expected: testutils_test.RemoveTestExpectedValues{
6968
Items: []string{
7069
"transformer2.yaml",
7170
"transformer3.yaml",
@@ -75,14 +74,14 @@ func TestRemoveTransformer(t *testing.T) {
7574
},
7675
{
7776
Description: "no arguments",
78-
Given: testutils_test.Given{},
79-
Expected: testutils_test.Expected{
77+
Given: testutils_test.RemoveTestGivenValues{},
78+
Expected: testutils_test.RemoveTestExpectedValues{
8079
Err: errors.Errorf("must specify a transformer file"),
8180
},
8281
},
8382
{
8483
Description: "remove with multiple pattern arguments",
85-
Given: testutils_test.Given{
84+
Given: testutils_test.RemoveTestGivenValues{
8685
Items: []string{
8786
"foo/foo.yaml",
8887
"bar/bar.yaml",
@@ -95,7 +94,7 @@ func TestRemoveTransformer(t *testing.T) {
9594
"tra*.yaml",
9695
},
9796
},
98-
Expected: testutils_test.Expected{
97+
Expected: testutils_test.RemoveTestExpectedValues{
9998
Items: []string{
10099
"do/not/deleteme/please.yaml",
101100
},

kustomize/commands/internal/testutils/remove_testutils.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,40 +12,40 @@ import (
1212
"sigs.k8s.io/kustomize/kyaml/filesys"
1313
)
1414

15-
// Given represents the provided inputs for the test case.
16-
type Given struct {
15+
// RemoveTestGivenValues represents the provided inputs for the test case.
16+
type RemoveTestGivenValues struct {
1717
// Items is the given input items.
1818
Items []string
1919
// RemoveArgs are the arguments to pass to the remove command.
2020
RemoveArgs []string
2121
}
2222

23-
// Expected represents the expected outputs of the test case.
24-
type Expected struct {
25-
// Expected is the collection of expected output items.
23+
// RemoveTestExpectedValues represents the expected outputs of the test case.
24+
type RemoveTestExpectedValues struct {
25+
// RemoveTestExpectedValues is the collection of expected output items.
2626
Items []string
2727
// Deleted is the collection of expected Deleted items (if any).
2828
Deleted []string
2929
// Err represents the error that is expected in the output (if any).
3030
Err error
3131
}
3232

33-
// Case represents a test case to execute.
34-
type Case struct {
33+
// RemoveTestCase represents a test case to execute.
34+
type RemoveTestCase struct {
3535
// Description is the description of the test case.
3636
Description string
3737
// Given is the provided inputs for the test case.
38-
Given Given
38+
Given RemoveTestGivenValues
3939
// Expected is the expected outputs for the test case.
40-
Expected Expected
40+
Expected RemoveTestExpectedValues
4141
}
4242

4343
// ExecuteRemoveTestCases executes the provided test cases against the specified command
4444
// for a particular collection (e.g. ) tests a command defined by the provided
4545
// collection Name (e.g. transformers or resources) and newRemoveCmdToTest function.
4646
func ExecuteRemoveTestCases(
4747
t *testing.T,
48-
testCases []Case,
48+
testCases []RemoveTestCase,
4949
collectionName string,
5050
newRemoveCmdToTest func(filesys.FileSystem) *cobra.Command,
5151
) {
@@ -64,7 +64,7 @@ func ExecuteRemoveTestCases(
6464
t.Errorf("unexpected cmd error: %v", err)
6565
} else if tc.Expected.Err != nil {
6666
if err.Error() != tc.Expected.Err.Error() {
67-
t.Errorf("expected error did not occurred. Expected: %v. Actual: %v",
67+
t.Errorf("expected error did not occur. Expected: %v. Actual: %v",
6868
tc.Expected.Err,
6969
err)
7070
}

0 commit comments

Comments
 (0)