From c0e201d638fba6711cdfd935fb12cb41bcf1725e Mon Sep 17 00:00:00 2001 From: Samir Patel <48686912+54mir@users.noreply.github.com> Date: Thu, 4 Nov 2021 12:19:56 -0500 Subject: [PATCH] dedup api_test --- api_test.go | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/api_test.go b/api_test.go index 05fd3acf9..1ac27ba02 100644 --- a/api_test.go +++ b/api_test.go @@ -254,16 +254,9 @@ func TestAPI_ImportValue(t *testing.T) { t.Run("ValIntEmpty", func(t *testing.T) { ctx := context.Background() index := "valintempty" - field := "f" - - _, err := coord.API.CreateIndex(ctx, index, pilosa.IndexOptions{Keys: true}) - if err != nil { - t.Fatalf("creating index: %v", err) - } - _, err = coord.API.CreateField(ctx, index, field, pilosa.OptFieldTypeInt(math.MinInt64, math.MaxInt64)) - if err != nil { - t.Fatalf("creating field: %v", err) - } + field := "fld" + createIndexForTest(index, coord, t) + createFieldForTest(index, field, coord, t) // Column keys are sharded so their order is not guaranteed. colKeys := []string{"col2", "col1", "col3"} @@ -1262,3 +1255,19 @@ func TestAPI_MutexCheck(t *testing.T) { }) } } + +func createIndexForTest(index string, coord *test.Command, t *testing.T) { + ctx := context.Background() + _, err := coord.API.CreateIndex(ctx, index, pilosa.IndexOptions{Keys: true}) + if err != nil { + t.Fatalf("creating index: %v", err) + } +} + +func createFieldForTest(index string, field string, coord *test.Command, t *testing.T) { + ctx := context.Background() + _, err := coord.API.CreateField(ctx, index, field, pilosa.OptFieldTypeInt(math.MinInt64, math.MaxInt64)) + if err != nil { + t.Fatalf("creating field: %v", err) + } +}