Skip to content

Commit

Permalink
TOOM-200: test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
b00lduck committed Jul 11, 2016
1 parent bd3628f commit e38d6f6
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion composition/composition_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,24 @@ func Test_CompositionHandler_ErrorInFetching(t *testing.T) {
a.Equal(502, resp.Code)
}

func Test_CompositionHandler_ErrorEmptyFetchersList(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
a := assert.New(t)

contentFetcherFactory := func(r *http.Request) FetchResultSupplier {
return MockFetchResultSupplier{}
}
aggregator := NewCompositionHandler(ContentFetcherFactory(contentFetcherFactory))

resp := httptest.NewRecorder()
r, _ := http.NewRequest("GET", "http://example.com", nil)
aggregator.ServeHTTP(resp, r)

a.Equal("Internal server error", string(resp.Body.Bytes()))
a.Equal(500, resp.Code)
}

func Test_metadataForRequest(t *testing.T) {
a := assert.New(t)
r, _ := http.NewRequest("GET", "https://example.com/nothing?foo=bar", nil)
Expand Down Expand Up @@ -267,6 +285,6 @@ func (m MockFetchResultSupplier) MetaJSON() map[string]interface{} {
}

func (m MockFetchResultSupplier) Empty() bool {
return false
return len([]*FetchResult(m)) == 0
}

0 comments on commit e38d6f6

Please sign in to comment.