mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-09-11 07:11:02 +00:00
Merge pull request #1386 from pilosa/client-test-cleanup
move pilosa/test/client.go helpers into pilosa/client_test.go
This commit is contained in:
commit
2fc9f41806
2 changed files with 21 additions and 42 deletions
|
|
@ -148,10 +148,10 @@ func TestClient_MultiNode(t *testing.T) {
|
|||
hldr[2].MustCreateRankedFragmentIfNotExists("i", "f", pilosa.ViewStandard, sliceNums[2]).RecalculateCache()
|
||||
|
||||
// Connect to each node to compare results.
|
||||
client := make([]*test.Client, 3)
|
||||
client[0] = test.MustNewClient(s[0].Host(), defaultClient)
|
||||
client[1] = test.MustNewClient(s[1].Host(), defaultClient)
|
||||
client[2] = test.MustNewClient(s[2].Host(), defaultClient)
|
||||
client := make([]*Client, 3)
|
||||
client[0] = MustNewClient(s[0].Host(), defaultClient)
|
||||
client[1] = MustNewClient(s[1].Host(), defaultClient)
|
||||
client[2] = MustNewClient(s[2].Host(), defaultClient)
|
||||
|
||||
topN := 4
|
||||
queryRequest := &internal.QueryRequest{
|
||||
|
|
@ -231,7 +231,7 @@ func TestClient_Import(t *testing.T) {
|
|||
s.Handler.API.Holder = hldr.Holder
|
||||
|
||||
// Send import request.
|
||||
c := test.MustNewClient(s.Host(), defaultClient)
|
||||
c := MustNewClient(s.Host(), defaultClient)
|
||||
if err := c.Import(context.Background(), "i", "f", 0, []pilosa.Bit{
|
||||
{RowID: 0, ColumnID: 1},
|
||||
{RowID: 0, ColumnID: 5},
|
||||
|
|
@ -276,7 +276,7 @@ func TestClient_ImportValue(t *testing.T) {
|
|||
s.Handler.API.Holder = hldr.Holder
|
||||
|
||||
// Send import request.
|
||||
c := test.MustNewClient(s.Host(), defaultClient)
|
||||
c := MustNewClient(s.Host(), defaultClient)
|
||||
if err := c.ImportValue(context.Background(), "i", "f", 0, []pilosa.FieldValue{
|
||||
{ColumnID: 1, Value: -10},
|
||||
{ColumnID: 2, Value: 20},
|
||||
|
|
@ -345,7 +345,7 @@ func TestClient_FragmentBlocks(t *testing.T) {
|
|||
s.Handler.API.Holder = hldr.Holder
|
||||
|
||||
// Retrieve blocks.
|
||||
c := test.MustNewClient(s.Host(), defaultClient)
|
||||
c := MustNewClient(s.Host(), defaultClient)
|
||||
blocks, err := c.FragmentBlocks(context.Background(), nil, "i", "f", 0)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
|
|
@ -362,3 +362,17 @@ func TestClient_FragmentBlocks(t *testing.T) {
|
|||
t.Fatalf("blocks mismatch:\n\nexp=%s\n\ngot=%s\n\n", spew.Sdump(a), spew.Sdump(blocks))
|
||||
}
|
||||
}
|
||||
|
||||
// Client represents a test wrapper for pilosa.Client.
|
||||
type Client struct {
|
||||
*http.InternalClient
|
||||
}
|
||||
|
||||
// MustNewClient returns a new instance of Client. Panic on error.
|
||||
func MustNewClient(host string, h *gohttp.Client) *Client {
|
||||
c, err := http.NewInternalClient(host, h)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return &Client{InternalClient: c}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,35 +0,0 @@
|
|||
// Copyright 2017 Pilosa Corp.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package test
|
||||
|
||||
import (
|
||||
gohttp "net/http"
|
||||
|
||||
"github.com/pilosa/pilosa/http"
|
||||
)
|
||||
|
||||
// Client represents a test wrapper for pilosa.Client.
|
||||
type Client struct {
|
||||
*http.InternalClient
|
||||
}
|
||||
|
||||
// MustNewClient returns a new instance of Client. Panic on error.
|
||||
func MustNewClient(host string, h *gohttp.Client) *Client {
|
||||
c, err := http.NewInternalClient(host, h)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return &Client{InternalClient: c}
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue