Skip to content
This repository has been archived by the owner on Sep 28, 2022. It is now read-only.

Commit

Permalink
100% coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
yuce committed Sep 21, 2017
1 parent 24a5c90 commit c8954ec
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions client_it_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,16 @@ func TestQueryWithEmptyClusterFails(t *testing.T) {
}
}

func TestMaxHostsFail(t *testing.T) {
uri, _ := NewURIFromAddress("does-not-resolve.foo.bar")
cluster := NewClusterWithHost(uri, uri, uri, uri)
client := NewClientWithCluster(cluster, nil)
_, err := client.Query(index.RawQuery("foo"), nil)
if err != ErrorTriedMaxHosts {
t.Fatalf("ErrorTriedMaxHosts error should be returned")
}
}

func TestQueryInverseBitmap(t *testing.T) {
client := getClient()
options := &FrameOptions{
Expand Down Expand Up @@ -817,6 +827,27 @@ func TestExportReaderFailure(t *testing.T) {
}
}

func TestExportReaderReadBodyFailure(t *testing.T) {
server := getMockServer(200, []byte("not important"), 100)
defer server.Close()
uri, err := NewURIFromAddress(server.URL)
if err != nil {
t.Fatal(err)
}
frame, err := index.Frame("exportframe", nil)
if err != nil {
t.Fatal(err)
}
sliceURIs := map[uint64]*URI{0: uri}
client := NewClientWithURI(uri)
reader := newExportReader(client, sliceURIs, frame, "standard")
buf := make([]byte, 1000)
_, err = reader.Read(buf)
if err == nil {
t.Fatal("should have failed")
}
}

func TestFetchFragmentNodes(t *testing.T) {
client := getClient()
nodes, err := client.fetchFragmentNodes(index.Name(), 0)
Expand Down Expand Up @@ -1101,6 +1132,21 @@ func TestImportNodeFails(t *testing.T) {
}
}

func TestImportNodeProtobufMarshalFails(t *testing.T) {
// even though this function isn't really an integration test,
// it needs to access importNode which is not
// available to client_test.go
client := getClient()
uri, err := NewURIFromAddress("http://does-not-matter.foo.bar")
if err != nil {
t.Fatal(err)
}
err = client.importNode(uri, nil)
if err == nil {
t.Fatalf("Should have failed")
}
}

func TestResponseWithInvalidType(t *testing.T) {
qr := &internal.QueryResponse{
Err: "",
Expand Down

0 comments on commit c8954ec

Please sign in to comment.