feat(goctl): Add api parser (#2585)
This commit is contained in:
32
tools/goctl/pkg/parser/api/assertx/error.go
Normal file
32
tools/goctl/pkg/parser/api/assertx/error.go
Normal file
@@ -0,0 +1,32 @@
|
||||
package assertx
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
// ErrorOrigin is used to assert error and print source and error.
|
||||
func ErrorOrigin(t *testing.T, source string, err ...error) {
|
||||
if len(err) == 0 {
|
||||
t.Fatalf("expected errors, got 0 error")
|
||||
return
|
||||
}
|
||||
for _, e := range err {
|
||||
fmt.Printf("<%s>: %v\n", source, e)
|
||||
assert.Error(t, e)
|
||||
}
|
||||
}
|
||||
|
||||
// Error is used to assert error.
|
||||
func Error(t *testing.T, err ...error) {
|
||||
if len(err) == 0 {
|
||||
t.Fatalf("expected errors, got 0 error")
|
||||
return
|
||||
}
|
||||
for _, e := range err {
|
||||
fmt.Println(e)
|
||||
assert.Error(t, e)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user