mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-22 03:11:40 +00:00
Check expected error value in annotate_test.TestUpdateAnnotations
This commit is contained in:
parent
9feaf478c6
commit
78cca63817
@ -227,7 +227,7 @@ func TestUpdateAnnotations(t *testing.T) {
|
|||||||
annotations map[string]string
|
annotations map[string]string
|
||||||
remove []string
|
remove []string
|
||||||
expected runtime.Object
|
expected runtime.Object
|
||||||
expectErr bool
|
expectedErr string
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
obj: &v1.Pod{
|
obj: &v1.Pod{
|
||||||
@ -249,7 +249,7 @@ func TestUpdateAnnotations(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
annotations: map[string]string{"a": "c"},
|
annotations: map[string]string{"a": "c"},
|
||||||
expectErr: true,
|
expectedErr: "--overwrite is false but found the following declared annotation(s): 'a' already has a value (b)",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
obj: &v1.Pod{
|
obj: &v1.Pod{
|
||||||
@ -378,13 +378,16 @@ func TestUpdateAnnotations(t *testing.T) {
|
|||||||
resourceVersion: test.version,
|
resourceVersion: test.version,
|
||||||
}
|
}
|
||||||
err := options.updateAnnotations(test.obj)
|
err := options.updateAnnotations(test.obj)
|
||||||
if test.expectErr {
|
if test.expectedErr != "" {
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Errorf("unexpected non-error: %v", test)
|
t.Errorf("unexpected non-error: %v", test)
|
||||||
}
|
}
|
||||||
|
if err.Error() != test.expectedErr {
|
||||||
|
t.Errorf("error expected: %v, got: %v", test.expectedErr, err.Error())
|
||||||
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if !test.expectErr && err != nil {
|
if test.expectedErr == "" && err != nil {
|
||||||
t.Errorf("unexpected error: %v %v", err, test)
|
t.Errorf("unexpected error: %v %v", err, test)
|
||||||
}
|
}
|
||||||
if !reflect.DeepEqual(test.obj, test.expected) {
|
if !reflect.DeepEqual(test.obj, test.expected) {
|
||||||
|
Loading…
Reference in New Issue
Block a user