Commit a1b535f9 authored by xiangpengzhao's avatar xiangpengzhao

Call Fatalf instead of Errorf when loading schema returns error

parent 812b87c8
......@@ -135,7 +135,7 @@ func TestLoad(t *testing.T) {
func TestValidateOk(t *testing.T) {
schema, err := loadSchemaForTest()
if err != nil {
t.Errorf("Failed to load: %v", err)
t.Fatalf("Failed to load: %v", err)
}
tests := []struct {
obj runtime.Object
......@@ -167,7 +167,7 @@ func TestValidateOk(t *testing.T) {
func TestValidateDifferentApiVersions(t *testing.T) {
schema, err := loadSchemaForTest()
if err != nil {
t.Errorf("Failed to load: %v", err)
t.Fatalf("Failed to load: %v", err)
}
pod := &api.Pod{}
......@@ -203,7 +203,7 @@ func TestValidateDifferentApiVersions(t *testing.T) {
func TestInvalid(t *testing.T) {
schema, err := loadSchemaForTest()
if err != nil {
t.Errorf("Failed to load: %v", err)
t.Fatalf("Failed to load: %v", err)
}
tests := []string{
"invalidPod1.json", // command is a string, instead of []string.
......@@ -227,7 +227,7 @@ func TestInvalid(t *testing.T) {
func TestValid(t *testing.T) {
schema, err := loadSchemaForTest()
if err != nil {
t.Errorf("Failed to load: %v", err)
t.Fatalf("Failed to load: %v", err)
}
tests := []string{
"validPod.yaml",
......@@ -239,7 +239,7 @@ func TestValid(t *testing.T) {
}
err = schema.ValidateBytes(pod)
if err != nil {
t.Errorf("unexpected error %s, for pod %s", err, pod)
t.Errorf("unexpected error: %s, for pod %s", err, pod)
}
}
}
......@@ -274,7 +274,7 @@ func TestVersionRegex(t *testing.T) {
// Tests that validation works fine when spec contains "type": "any" instead of "type": "object"
// Ref: https://github.com/kubernetes/kubernetes/issues/24309
func TestTypeOAny(t *testing.T) {
func TestTypeAny(t *testing.T) {
data, err := readSwaggerFile()
if err != nil {
t.Errorf("failed to read swagger file: %v", err)
......@@ -283,7 +283,7 @@ func TestTypeOAny(t *testing.T) {
newData := strings.Replace(string(data), `"type": "object"`, `"type": "any"`, -1)
schema, err := NewSwaggerSchemaFromBytes([]byte(newData), nil)
if err != nil {
t.Errorf("Failed to load: %v", err)
t.Fatalf("Failed to load: %v", err)
}
tests := []string{
"validPod.yaml",
......@@ -304,7 +304,7 @@ func TestTypeOAny(t *testing.T) {
}
err = schema.ValidateBytes(podBytes)
if err != nil {
t.Errorf("unexpected error %s, for pod %s", err, string(podBytes))
t.Errorf("unexpected error: %s, for pod %s", err, string(podBytes))
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment