server: add error helper
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
19
server/errors_test.go
Normal file
19
server/errors_test.go
Normal file
@@ -0,0 +1,19 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/unistack-org/micro/v3/errors"
|
||||
)
|
||||
|
||||
func TestError(t *testing.T) {
|
||||
e := NewError("svc1")
|
||||
err := e.BadRequest("%s", "test")
|
||||
merr, ok := err.(*errors.Error)
|
||||
if !ok {
|
||||
t.Fatal("error not *errors.Error")
|
||||
}
|
||||
if merr.Id != "svc1" {
|
||||
t.Fatal("id != svc1")
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user