Skip to content

Commit

Permalink
Add a test for elasticsearch.FilterF
Browse files Browse the repository at this point in the history
  • Loading branch information
korfuri committed Jul 17, 2017
1 parent cd4818b commit 38e44c3
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions elasticsearch/filterf_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package elasticsearch_test

import (
"errors"
"testing"

"github.com/korfuri/goref/elasticsearch"
"github.com/korfuri/goref/elasticsearch/mocks"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
elastic "gopkg.in/olivere/elastic.v5"
)

func TestFilterF(t *testing.T) {
client := &mocks.Client{}
client.On("GetPackage", mock.Anything, "v1@0@a").Return(&elastic.GetResult{}, nil)
client.On("GetPackage", mock.Anything, "v1@0@b").Return(nil, errors.New("404"))

f := elasticsearch.FilterF(client)
assert.False(t, f("a", 0))
assert.True(t, f("b", 0))
}

0 comments on commit 38e44c3

Please sign in to comment.