mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-11 00:52:55 +00:00
Delete newly orphaned code.
This commit is contained in:
@@ -466,278 +466,6 @@ func TestGetString(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetInt64(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
pathToField string
|
||||
expectedValue int64
|
||||
errorExpected bool
|
||||
errorMsg string
|
||||
}{
|
||||
{
|
||||
name: "numberAsValue",
|
||||
pathToField: "this.is.aNumber",
|
||||
errorExpected: false,
|
||||
expectedValue: int64(1000),
|
||||
},
|
||||
{
|
||||
name: "validStructSubFieldIndexSubfield",
|
||||
pathToField: "complextree[1].field2[1].intsubfield",
|
||||
errorExpected: false,
|
||||
expectedValue: int64(1121),
|
||||
},
|
||||
{
|
||||
name: "twoFieldsOneMissing",
|
||||
pathToField: "metadata.banana",
|
||||
errorExpected: true,
|
||||
errorMsg: "no field named 'metadata.banana'",
|
||||
},
|
||||
{
|
||||
name: "validStructSubFieldOutOfBoundIndex",
|
||||
pathToField: "these[1].field2[99]",
|
||||
errorExpected: true,
|
||||
errorMsg: "no field named 'these[1].field2[99]'",
|
||||
},
|
||||
{
|
||||
name: "validDownwardAPISpecs",
|
||||
pathToField: `spec.ports['port']`,
|
||||
errorExpected: false,
|
||||
expectedValue: int64(80),
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
s, err := kunstructured.GetInt64(test.pathToField)
|
||||
if test.errorExpected {
|
||||
compareExpectedError(t, test.name, test.pathToField, err, test.errorMsg)
|
||||
continue
|
||||
}
|
||||
if err != nil {
|
||||
unExpectedError(t, test.name, test.pathToField, err)
|
||||
}
|
||||
compareValues(t, test.name, test.pathToField, test.expectedValue, s)
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetFloat64(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
pathToField string
|
||||
expectedValue float64
|
||||
errorExpected bool
|
||||
errorMsg string
|
||||
}{
|
||||
{
|
||||
name: "floatAsValue",
|
||||
pathToField: "this.is.aFloat",
|
||||
errorExpected: false,
|
||||
expectedValue: float64(1.001),
|
||||
},
|
||||
{
|
||||
name: "validStructSubFieldIndexSubfield",
|
||||
pathToField: "complextree[1].field2[1].floatsubfield",
|
||||
errorExpected: false,
|
||||
expectedValue: float64(1.1121),
|
||||
},
|
||||
{
|
||||
name: "validDownwardAPIThis",
|
||||
pathToField: `this.is[aFloat]`,
|
||||
errorExpected: false,
|
||||
expectedValue: float64(1.001),
|
||||
},
|
||||
{
|
||||
name: "twoFieldsOneMissing",
|
||||
pathToField: "metadata.banana",
|
||||
errorExpected: true,
|
||||
errorMsg: "no field named 'metadata.banana'",
|
||||
},
|
||||
{
|
||||
name: "validStructSubFieldOutOfBoundIndex",
|
||||
pathToField: "these[1].field2[99]",
|
||||
errorExpected: true,
|
||||
errorMsg: "index 99 is out of bounds",
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
s, err := kunstructured.GetFloat64(test.pathToField)
|
||||
if test.errorExpected {
|
||||
compareExpectedError(t, test.name, test.pathToField, err, test.errorMsg)
|
||||
continue
|
||||
}
|
||||
if err != nil {
|
||||
unExpectedError(t, test.name, test.pathToField, err)
|
||||
}
|
||||
compareValues(t, test.name, test.pathToField, test.expectedValue, s)
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetBool(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
pathToField string
|
||||
expectedValue bool
|
||||
errorExpected bool
|
||||
errorMsg string
|
||||
}{
|
||||
{
|
||||
name: "boolAsValue",
|
||||
pathToField: "this.is.aBool",
|
||||
errorExpected: false,
|
||||
expectedValue: true,
|
||||
},
|
||||
{
|
||||
name: "validStructSubFieldIndexSubfield",
|
||||
pathToField: "complextree[1].field2[1].boolfield",
|
||||
errorExpected: false,
|
||||
expectedValue: false,
|
||||
},
|
||||
{
|
||||
name: "twoFieldsOneMissing",
|
||||
pathToField: "metadata.banana",
|
||||
errorExpected: true,
|
||||
errorMsg: "no field named 'metadata.banana'",
|
||||
},
|
||||
{
|
||||
name: "validStructSubFieldOutOfBoundIndex",
|
||||
pathToField: "these[1].field2[99]",
|
||||
errorExpected: true,
|
||||
errorMsg: "no field named 'these[1].field2[99]'",
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
s, err := kunstructured.GetBool(test.pathToField)
|
||||
if test.errorExpected {
|
||||
compareExpectedError(t, test.name, test.pathToField, err, test.errorMsg)
|
||||
continue
|
||||
}
|
||||
if err != nil {
|
||||
unExpectedError(t, test.name, test.pathToField, err)
|
||||
}
|
||||
compareValues(t, test.name, test.pathToField, test.expectedValue, s)
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetStringMap(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
pathToField string
|
||||
errorExpected bool
|
||||
errorMsg string
|
||||
}{
|
||||
{
|
||||
name: "validStringMap",
|
||||
pathToField: "those[2]",
|
||||
errorExpected: false,
|
||||
},
|
||||
{
|
||||
name: "twoFieldsOneMissing",
|
||||
pathToField: "metadata.banana",
|
||||
errorExpected: true,
|
||||
errorMsg: "no field named 'metadata.banana'",
|
||||
},
|
||||
{
|
||||
name: "validStructSubFieldOutOfBoundIndex",
|
||||
pathToField: "these[1].field2[99]",
|
||||
errorExpected: true,
|
||||
errorMsg: "no field named 'these[1].field2[99]'",
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
_, err := kunstructured.GetStringMap(test.pathToField)
|
||||
if test.errorExpected {
|
||||
compareExpectedError(t, test.name, test.pathToField, err, test.errorMsg)
|
||||
continue
|
||||
}
|
||||
if err != nil {
|
||||
unExpectedError(t, test.name, test.pathToField, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetMap(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
pathToField string
|
||||
errorExpected bool
|
||||
errorMsg string
|
||||
}{
|
||||
{
|
||||
name: "validMap",
|
||||
pathToField: "those[2]",
|
||||
errorExpected: false,
|
||||
},
|
||||
{
|
||||
name: "validStructSubFieldIndexSubfield",
|
||||
pathToField: "complextree[1].field2[1]",
|
||||
errorExpected: false,
|
||||
},
|
||||
{
|
||||
name: "twoFieldsOneMissing",
|
||||
pathToField: "metadata.banana",
|
||||
errorExpected: true,
|
||||
errorMsg: "no field named 'metadata.banana'",
|
||||
},
|
||||
{
|
||||
name: "validStructSubFieldOutOfBoundIndex",
|
||||
pathToField: "these[1].field2[99]",
|
||||
errorExpected: true,
|
||||
errorMsg: "no field named 'these[1].field2[99]'",
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
_, err := kunstructured.GetMap(test.pathToField)
|
||||
if test.errorExpected {
|
||||
compareExpectedError(t, test.name, test.pathToField, err, test.errorMsg)
|
||||
continue
|
||||
}
|
||||
if err != nil {
|
||||
unExpectedError(t, test.name, test.pathToField, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetStringSlice(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
pathToField string
|
||||
errorExpected bool
|
||||
errorMsg string
|
||||
}{
|
||||
{
|
||||
name: "validStringSlice",
|
||||
pathToField: "that",
|
||||
errorExpected: false,
|
||||
},
|
||||
{
|
||||
name: "twoFieldsOneMissing",
|
||||
pathToField: "metadata.banana",
|
||||
errorExpected: true,
|
||||
errorMsg: "no field named 'metadata.banana'",
|
||||
},
|
||||
{
|
||||
name: "validStructSubFieldOutOfBoundIndex",
|
||||
pathToField: "these[1].field2[99]",
|
||||
errorExpected: true,
|
||||
errorMsg: "no field named 'these[1].field2[99]'",
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
_, err := kunstructured.GetStringSlice(test.pathToField)
|
||||
if test.errorExpected {
|
||||
compareExpectedError(t, test.name, test.pathToField, err, test.errorMsg)
|
||||
continue
|
||||
}
|
||||
if err != nil {
|
||||
unExpectedError(t, test.name, test.pathToField, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetSlice(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
|
||||
Reference in New Issue
Block a user