From 2bc2640fbfa465c03387d462fc84ad3b07c4b2d7 Mon Sep 17 00:00:00 2001 From: Samir Patel <48686912+54mir@users.noreply.github.com> Date: Tue, 2 Nov 2021 15:50:48 -0500 Subject: [PATCH] test two scenarios --- api_test.go | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/api_test.go b/api_test.go index 378aee9fd..05fd3acf9 100644 --- a/api_test.go +++ b/api_test.go @@ -251,6 +251,43 @@ 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) + } + + // Column keys are sharded so their order is not guaranteed. + colKeys := []string{"col2", "col1", "col3"} + + // Import without data, verify that it succeeds + req := &pilosa.ImportValueRequest{ + Index: index, + Field: field, + } + qcx1 := coord.API.Txf().NewQcx() + if err := coord.API.ImportValue(ctx, qcx1, req); err != nil { + t.Fatal(err) + } + PanicOn(qcx1.Finish()) + + // Import without data but with columnkeys, verify that it errors + req.ColumnKeys = colKeys + qcx2 := coord.API.Txf().NewQcx() + if err := coord.API.ImportValue(ctx, qcx2, req); err == nil { + t.Fatal("expected error but succeeded") + } + PanicOn(qcx2.Finish()) + }) + t.Run("ValDecimalField", func(t *testing.T) { ctx := context.Background() index := "valdec"