Added gock call validation

This commit is contained in:
Héctor Hurtado
2019-10-03 10:43:51 +02:00
parent 332d897927
commit 8b7d1d69e7
+20
View File
@@ -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")
}
}