Skip to content

Commit

Permalink
fixed one test and added one more
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastian Mancke committed Jul 11, 2016
1 parent c7e0b31 commit 5039b0f
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion composition/cache_loader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,32 @@ func Test_CacheLoader_Found(t *testing.T) {
a.Equal(c, result)
}

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

// given:
fd := NewFetchDefinition("/foo")
fd.Method = "POST"
c := NewMemoryContent()
c.url = "/foo"

// and a cache returning nothing
cacheMocK := NewMockCache(ctrl)
httpLoaderMocK := NewMockContentLoader(ctrl)
httpLoaderMocK.EXPECT().Load(gomock.Any()).Return(c, nil)

// when: we load the object
loader := NewCachingContentLoader(cacheMocK)
loader.httpContentLoader = httpLoaderMocK

// it is returned
result, err := loader.Load(fd)
a.NoError(err)
a.Equal(c, result)
}

func Test_CacheLoader_NotFound(t *testing.T) {
tests := []struct {
url string
Expand All @@ -41,7 +67,6 @@ func Test_CacheLoader_NotFound(t *testing.T) {
}{
{"http://example.de", "GET", true},
{"file:///some/file", "GET", true},
{"http://example.de", "POST", false},
}
for _, test := range tests {
ctrl := gomock.NewController(t)
Expand Down

0 comments on commit 5039b0f

Please sign in to comment.