mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-25 20:53:33 +00:00
Merge pull request #104761 from lauchokyip/improveCM
Improve create configmap test
This commit is contained in:
commit
ff593c89a0
@ -21,6 +21,8 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
corev1 "k8s.io/api/core/v1"
|
corev1 "k8s.io/api/core/v1"
|
||||||
apiequality "k8s.io/apimachinery/pkg/api/equality"
|
apiequality "k8s.io/apimachinery/pkg/api/equality"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
@ -441,21 +443,18 @@ func TestCreateConfigMap(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
err := configMapOptions.Validate()
|
err := configMapOptions.Validate()
|
||||||
|
|
||||||
if err == nil {
|
if err == nil {
|
||||||
configMap, err = configMapOptions.createConfigMap()
|
configMap, err = configMapOptions.createConfigMap()
|
||||||
}
|
}
|
||||||
|
if test.expectErr == "" {
|
||||||
if test.expectErr == "" && err != nil {
|
require.NoError(t, err)
|
||||||
t.Errorf("unexpected error: %v", err)
|
if !apiequality.Semantic.DeepEqual(configMap, test.expected) {
|
||||||
}
|
t.Errorf("\nexpected:\n%#v\ngot:\n%#v", test.expected, configMap)
|
||||||
if test.expectErr != "" && err == nil {
|
}
|
||||||
t.Errorf("was expecting an error but no error occurred")
|
} else {
|
||||||
}
|
require.Error(t, err)
|
||||||
if test.expectErr != "" && test.expectErr != err.Error() {
|
require.EqualError(t, err, test.expectErr)
|
||||||
t.Errorf("\nexpected error:\n%s\ngot error:\n%s", test.expectErr, err.Error())
|
|
||||||
}
|
|
||||||
if !apiequality.Semantic.DeepEqual(configMap, test.expected) {
|
|
||||||
t.Errorf("\nexpected:\n%#v\ngot:\n%#v", test.expected, configMap)
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user