Skip to content

Commit

Permalink
Add router test for service removal
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinmcconnell committed Sep 25, 2024
1 parent 566d53b commit ccd2018
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions internal/server/router_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,21 @@ func TestRouter_ActiveServiceForHost(t *testing.T) {
assert.Equal(t, "first", body)
}

func TestRouter_Removing(t *testing.T) {
router := testRouter(t)
_, target := testBackend(t, "first", http.StatusOK)

require.NoError(t, router.SetServiceTarget("service1", "dummy.example.com", target, defaultServiceOptions, defaultTargetOptions, DefaultDeployTimeout, DefaultDrainTimeout))

statusCode, body := sendGETRequest(router, "http://dummy.example.com/")
assert.Equal(t, http.StatusOK, statusCode)
assert.Equal(t, "first", body)

require.NoError(t, router.RemoveService("service1"))
statusCode, _ = sendGETRequest(router, "http://dummy.example.com/")
assert.Equal(t, http.StatusNotFound, statusCode)
}

func TestRouter_ActiveServiceForUnknownHost(t *testing.T) {
router := testRouter(t)
_, target := testBackend(t, "first", http.StatusOK)
Expand Down

0 comments on commit ccd2018

Please sign in to comment.