Skip to content

Commit

Permalink
fix: test cases failed
Browse files Browse the repository at this point in the history
  • Loading branch information
johzchen committed Jan 27, 2021
1 parent a99c92b commit 8c6ffa9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
12 changes: 6 additions & 6 deletions api/internal/handler/data_loader/route_import_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func TestImport_invalid_file_type(t *testing.T) {
input.FileName = "file1.txt"
input.FileContent = []byte("hello")

h := Handler{}
h := ImportHandler{}
ctx := droplet.NewContext()
ctx.SetInput(input)

Expand All @@ -80,7 +80,7 @@ func TestImport_invalid_content(t *testing.T) {
input.FileName = "file1.json"
input.FileContent = []byte(`{"test": "a"}`)

h := Handler{}
h := ImportHandler{}
ctx := droplet.NewContext()
ctx.SetInput(input)

Expand Down Expand Up @@ -110,7 +110,7 @@ func TestImport_with_service_id(t *testing.T) {
mStore.On("Get", mock.Anything).Run(func(args mock.Arguments) {
}).Return(nil, errors.New("data not found by key: service1"))

h := Handler{
h := ImportHandler{
routeStore: &store.GenericStore{},
svcStore: mStore,
upstreamStore: mStore,
Expand All @@ -126,7 +126,7 @@ func TestImport_with_service_id(t *testing.T) {
mStore.On("Get", mock.Anything).Run(func(args mock.Arguments) {
}).Return(nil, data.ErrNotFound)

h = Handler{
h = ImportHandler{
routeStore: &store.GenericStore{},
svcStore: mStore,
upstreamStore: mStore,
Expand All @@ -148,7 +148,7 @@ func TestImport_with_upstream_id(t *testing.T) {
mStore.On("Get", mock.Anything).Run(func(args mock.Arguments) {
}).Return(nil, errors.New("data not found by key: upstream1"))

h := Handler{
h := ImportHandler{
routeStore: &store.GenericStore{},
svcStore: mStore,
upstreamStore: mStore,
Expand All @@ -164,7 +164,7 @@ func TestImport_with_upstream_id(t *testing.T) {
mStore.On("Get", mock.Anything).Run(func(args mock.Arguments) {
}).Return(nil, data.ErrNotFound)

h = Handler{
h = ImportHandler{
routeStore: &store.GenericStore{},
svcStore: mStore,
upstreamStore: mStore,
Expand Down
10 changes: 8 additions & 2 deletions api/test/e2e/route_import_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,9 +300,15 @@ func TestImport_with_multi_routes(t *testing.T) {
Sleep: sleepTime,
}
tests = append(tests, tc)

uris := route["uris"].([]string)
isGet := false
for _, uri := range uris {
if uri == "/get" {
isGet = true
}
}
// verify route data
if route["uri"].(string) == "/get" {
if isGet {
tcDataVerify := HttpTestCase{
Desc: "verify data of route",
Object: ManagerApiExpect(t),
Expand Down

0 comments on commit 8c6ffa9

Please sign in to comment.