Skip to content

Commit

Permalink
Merge pull request FeatureBaseDB#2099 from kuba--/test-clear
Browse files Browse the repository at this point in the history
Add extra Clear test (check if existency column bit is set)
  • Loading branch information
kuba-- authored Feb 13, 2020
2 parents 771cc3a + 377d140 commit ac3a4ab
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -675,6 +675,52 @@ func TestExecutor_Execute_Clear(t *testing.T) {
t.Fatalf("expected column changed")
}
})

t.Run("RowKeyColumnKey_NotClearNot", func(t *testing.T) {
writeQuery := `Set("one", f="ten")`
readQueries := []string{
`Not(Row(f="whatever"))`,
`Clear("one", f="whatever")`,
`Not(Row(f="whatever")) `,
`Clear("one", f="ten")`,
`Not(Row(f="whatever")) `,
}
results := []interface{}{
"one",
false,
"one",
true,
"one",
}

responses := runCallTest(t, writeQuery, readQueries, &pilosa.IndexOptions{
Keys: true,
TrackExistence: true,
}, pilosa.OptFieldKeys())
for i, resp := range responses {
if len(resp.Results) != 1 {
t.Fatalf("response %d: len(results) expected: 1, got: %d", i, len(resp.Results))
}

switch r := resp.Results[0].(type) {
case bool:
if results[i] != r {
t.Fatalf("response %d: expected: %v, got: %v", i, results[i], r)
}

case *pilosa.Row:
if len(r.Keys) != 1 {
t.Fatalf("response %d: len(keys) expected: 1, got: %d", i, len(r.Keys))
}
if results[i] != r.Keys[0] {
t.Fatalf("response %d: expected: %v, got: %v", i, results[i], r.Keys[0])
}

default:
t.Fatalf("response %d: expected: %T, got: %T", i, results[i], r)
}
}
})
}

// Ensure a set query can be executed on a bool field.
Expand Down

0 comments on commit ac3a4ab

Please sign in to comment.