Skip to content

Commit

Permalink
test: add test cases for service using int id
Browse files Browse the repository at this point in the history
  • Loading branch information
johzchen committed Nov 29, 2020
1 parent be45b00 commit c7b848b
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions api/test/e2e/id_compatible_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,40 @@ func TestID_Using_Int(t *testing.T) {
ExpectBody: "hello world",
Sleep: sleepTime,
},
{
caseDesc: "create service",
Object: MangerApiExpect(t),
Method: http.MethodPut,
Path: "/apisix/admin/services",
Body: `{
"id": 1,
"upstream_id": 1
}`,
Headers: map[string]string{"Authorization": token},
ExpectStatus: http.StatusOK,
},
{
caseDesc: "update route to use the service just created",
Object: MangerApiExpect(t),
Method: http.MethodPut,
Path: "/apisix/admin/routes/1",
Body: `{
"uri": "/hello",
"service_id": 1
}`,
Headers: map[string]string{"Authorization": token},
ExpectStatus: http.StatusOK,
Sleep: sleepTime,
},
{
caseDesc: "hit the route just updated",
Object: APISIXExpect(t),
Method: http.MethodGet,
Path: "/hello",
ExpectStatus: http.StatusOK,
ExpectBody: "hello world",
Sleep: sleepTime,
},
{
caseDesc: "delete the route",
Object: MangerApiExpect(t),
Expand All @@ -70,6 +104,24 @@ func TestID_Using_Int(t *testing.T) {
Headers: map[string]string{"Authorization": token},
ExpectStatus: http.StatusOK,
},
{
caseDesc: "delete the service",
Object: MangerApiExpect(t),
Method: http.MethodDelete,
Path: "/apisix/admin/services/1",
Headers: map[string]string{"Authorization": token},
ExpectStatus: http.StatusOK,
Sleep: sleepTime,
},
{
caseDesc: "make sure the service has been deleted",
Object: MangerApiExpect(t),
Method: http.MethodGet,
Path: "/apisix/admin/services/1",
Headers: map[string]string{"Authorization": token},
ExpectStatus: http.StatusNotFound,
Sleep: sleepTime,
},
{
caseDesc: "delete the upstream",
Object: MangerApiExpect(t),
Expand Down

0 comments on commit c7b848b

Please sign in to comment.