make tests slightly easier to write
This commit is contained in:
+7
-7
@@ -15,18 +15,18 @@ func TestReadParams(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, testCase := range testCases {
|
for _, tc := range testCases {
|
||||||
t.Log("Input:", testCase.Input)
|
t.Log("Input:", tc.Input)
|
||||||
t.Log("Expected output:", testCase.Output)
|
t.Log("Expected output:", tc.Output)
|
||||||
|
|
||||||
params := ReadParams(testCase.Input)
|
params := ReadParams(tc.Input)
|
||||||
|
|
||||||
if len(params) != len(testCase.Output) {
|
if len(params) != len(tc.Output) {
|
||||||
t.Errorf("Expected %d parameters", len(testCase.Output))
|
t.Errorf("Expected %d parameters", len(tc.Output))
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
for i, name := range testCase.Output {
|
for i, name := range tc.Output {
|
||||||
if params[i] != name {
|
if params[i] != name {
|
||||||
t.Errorf("Expected parameter %d to be %q", i, name)
|
t.Errorf("Expected parameter %d to be %q", i, name)
|
||||||
}
|
}
|
||||||
|
|||||||
+10
-10
@@ -27,24 +27,24 @@ RETURN doc`,
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, testCase := range testCases {
|
for _, tc := range testCases {
|
||||||
actualStr := testCase.Input.String()
|
actualStr := tc.Input.String()
|
||||||
|
|
||||||
if actualStr != testCase.ExpectedStr {
|
if actualStr != tc.ExpectedStr {
|
||||||
t.Logf("Expected: %q", testCase.ExpectedStr)
|
t.Logf("Expected: %q", tc.ExpectedStr)
|
||||||
t.Logf("Actual: %q", actualStr)
|
t.Logf("Actual: %q", actualStr)
|
||||||
t.Fail()
|
t.Fail()
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(testCase.Input.Params) != len(testCase.ExpectedParams) {
|
if len(tc.Input.Params) != len(tc.ExpectedParams) {
|
||||||
t.Errorf("Expected %d parameters; got %d", len(testCase.ExpectedParams), len(testCase.Input.Params))
|
t.Errorf("Expected %d parameters; got %d", len(tc.ExpectedParams), len(tc.Input.Params))
|
||||||
}
|
}
|
||||||
|
|
||||||
for name, value := range testCase.ExpectedParams {
|
for name, value := range tc.ExpectedParams {
|
||||||
if testCase.Input.Params[name] == nil {
|
if tc.Input.Params[name] == nil {
|
||||||
t.Errorf("Expected parameter %q to be %q; got nil", name, value)
|
t.Errorf("Expected parameter %q to be %q; got nil", name, value)
|
||||||
} else if testCase.Input.Params[name] != value {
|
} else if tc.Input.Params[name] != value {
|
||||||
t.Errorf("Expected parameter %q to be %q; got %q", name, value, testCase.Input.Params[name])
|
t.Errorf("Expected parameter %q to be %q; got %q", name, value, tc.Input.Params[name])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user