Files
kapow/internal/client/route_remove_test.go
pancho horrillo 013cd4d637 Add internal/client/route_remove{,_test}.go
Co-authored-by: Héctor Hurtado <hector.hurtado@bbva.com>
2019-10-03 18:22:18 +02:00

42 lines
929 B
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package client
import (
"net/http"
"testing"
gock "gopkg.in/h2non/gock.v1"
)
func TestRemoveRouteExistent(t *testing.T) {
const (
host = "http://localhost:8080"
routeID = "ROUTE_ID_OLDER_BUT_IT_CHECKS_OUT"
)
defer gock.Off()
gock.New(host).Delete("/routes/" + routeID).Reply(http.StatusNoContent)
err := RemoveRoute(host, routeID)
if err != nil {
t.Errorf("unexpected error: %s", err)
}
}
func TestRemoveRouteNonExistent(t *testing.T) {
const (
host = "http://localhost:8080"
routeID = "ROUTE_THIS_ONE_WONT_WORK_BUDDY"
)
expected := http.StatusText(http.StatusNotFound)
defer gock.Off()
gock.New(host).Delete("/routes/" + routeID).Reply(http.StatusNotFound)
err := RemoveRoute(host, routeID)
if err == nil {
t.Errorf("error not reported for nonexistent route")
} else if err.Error() != expected {
t.Errorf("error mismatch: expected %s, got %s", expected, err)
}
}