update tests

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
2021-03-06 22:24:49 +03:00
parent ba7d0703a3
commit 0cde3df915
5 changed files with 24 additions and 26 deletions

View File

@@ -26,6 +26,7 @@ import (
"github.com/unistack-org/micro/v3/api/router"
"github.com/unistack-org/micro/v3/broker"
"github.com/unistack-org/micro/v3/client"
"github.com/unistack-org/micro/v3/errors"
"github.com/unistack-org/micro/v3/register"
rt "github.com/unistack-org/micro/v3/router"
"github.com/unistack-org/micro/v3/server"
@@ -124,9 +125,16 @@ func check(t *testing.T, addr string, path string, expected string, timeout bool
t.Fatal(err)
}
jsonMsg := expected
if string(buf) != jsonMsg {
t.Fatalf("invalid message received, parsing error %s != %s", buf, jsonMsg)
reterr := errors.Parse(string(buf))
experr := errors.Parse(expected)
if reterr.Code != 0 || experr.Code != 0 {
if !errors.Equal(reterr, experr) {
t.Fatalf("invalid message received, parsing error %s != %s", buf, expected)
}
} else {
if string(buf) != expected {
t.Fatalf("invalid message received, parsing error %s != %s", buf, expected)
}
}
}