|
|
|
|
|
|
|
|
package validation |
|
|
package validation |
|
|
|
|
|
|
|
|
import ( |
|
|
import ( |
|
|
"fmt" |
|
|
|
|
|
"net/http" |
|
|
"net/http" |
|
|
"net/http/httptest" |
|
|
"net/http/httptest" |
|
|
"testing" |
|
|
"testing" |
|
|
|
|
|
|
|
|
m := macaron.Classic() |
|
|
m := macaron.Classic() |
|
|
|
|
|
|
|
|
m.Post(testRoute, binding.Validate(testCase.data), func(actual binding.Errors) { |
|
|
m.Post(testRoute, binding.Validate(testCase.data), func(actual binding.Errors) { |
|
|
assert.Equal(t, fmt.Sprintf("%+v", testCase.expectedErrors), fmt.Sprintf("%+v", actual)) |
|
|
|
|
|
|
|
|
// see https://github.com/stretchr/testify/issues/435 |
|
|
|
|
|
if actual == nil { |
|
|
|
|
|
actual = binding.Errors{} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
assert.Equal(t, testCase.expectedErrors, actual) |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
req, err := http.NewRequest("POST", testRoute, nil) |
|
|
req, err := http.NewRequest("POST", testRoute, nil) |