From 8b7d1d69e7eeee199d2e22d39f31e6c6dab9990d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Hurtado?= Date: Thu, 3 Oct 2019 10:43:51 +0200 Subject: [PATCH] Added gock call validation --- client/set_test.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/client/set_test.go b/client/set_test.go index e57fb1d..c99afe8 100644 --- a/client/set_test.go +++ b/client/set_test.go @@ -27,6 +27,10 @@ func TestNoContent(t *testing.T) { } else if err.Error() != expectedErr { t.Errorf("Error don't match: expected \"%s\", got \"%s\"", expectedErr, err.Error()) } + + if !gock.IsDone() { + t.Errorf("No endpoint called") + } } // Test that bad request errors are detected as invalid resource @@ -46,6 +50,10 @@ func TestBadRequest(t *testing.T) { } else if err.Error() != expectedErr { t.Errorf("Error don't match: expected \"%s\", got \"%s\"", expectedErr, err.Error()) } + + if !gock.IsDone() { + t.Errorf("No endpoint called") + } } // Test that not found errors are detected as invalid handler id @@ -65,6 +73,10 @@ func TestNotFound(t *testing.T) { } else if err.Error() != expectedErr { t.Errorf("Error don't match: expected \"%s\", got \"%s\"", expectedErr, err.Error()) } + + if !gock.IsDone() { + t.Errorf("No endpoint called") + } } // Test that internal server errors are detected correctly @@ -84,6 +96,10 @@ func TestInternalServerError(t *testing.T) { } else if err.Error() != expectedErr { t.Errorf("Error don't match: expected \"%s\", got \"%s\"", expectedErr, err.Error()) } + + if !gock.IsDone() { + t.Errorf("No endpoint called") + } } // Test a http ok request @@ -100,4 +116,8 @@ func TestOkRequest(t *testing.T) { if err := client.SetData(host, hid, path, reader); err != nil { t.Error("Unexpected error") } + + if !gock.IsDone() { + t.Errorf("No endpoint called") + } }