Skip to content

Commit

Permalink
Add the testing for empty data
Browse files Browse the repository at this point in the history
  • Loading branch information
hwchiu committed Jun 22, 2018
1 parent 713eb4f commit c95f1ce
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/server/handler_storage_provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,19 @@ func TestCreateStorageProvider(t *testing.T) {
service := newStorageProviderService(sp)
wc.Add(service)
wc.Dispatch(httpWriter, httpRequest)
defer session.Remove(entity.StorageProviderCollectionName, "displayName", tName)
assertResponseCode(t, http.StatusOK, httpWriter)
//Empty data
//We use the new write but empty input
httpWriter = httptest.NewRecorder()
wc.Dispatch(httpWriter, httpRequest)
assertResponseCode(t, http.StatusBadRequest, httpWriter)
//Create again and it should fail since the name exist
bodyReader = strings.NewReader(string(bodyBytes))
httpRequest, err = http.NewRequest("POST", "http://localhost:7890/v1/storageprovider", bodyReader)
assert.NoError(t, err)
httpRequest.Header.Add("Content-Type", "application/json")
httpWriter = httptest.NewRecorder()
wc.Dispatch(httpWriter, httpRequest)
assertResponseCode(t, http.StatusConflict, httpWriter)
defer session.Remove(entity.StorageProviderCollectionName, "displayName", tName)
}

0 comments on commit c95f1ce

Please sign in to comment.