mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-10-06 19:07:50 +00:00
add a couple more tests cases, refactor to table driven
this was some quick work I did in response to a possible issue that was reported. It didn't turn out to be a problem on our end and these tests confirmed that, but I think this is worth checking in.
This commit is contained in:
parent
724863bb1b
commit
630d510f85
2 changed files with 31 additions and 20 deletions
|
|
@ -1092,27 +1092,22 @@ func TestExecutor(t *testing.T) {
|
|||
{"R1", "C6"},
|
||||
})
|
||||
|
||||
tr := c.QueryGRPC(t, indexName, "Row(f1=R1, from='2022-01-10', to='2022-01-13')")
|
||||
csvString, err := tableResponseToCSVString(tr)
|
||||
if err != nil {
|
||||
t.Fatalf("converting to CSV: %v", err)
|
||||
}
|
||||
expected := `
|
||||
tests := []struct {
|
||||
query string
|
||||
expected string
|
||||
}{
|
||||
{
|
||||
query: "Row(f1=R1, from='2022-01-10', to='2022-01-13')",
|
||||
expected: `
|
||||
_id
|
||||
C1
|
||||
C3
|
||||
C2
|
||||
`[1:]
|
||||
// check that an unqualified query does use the standard view
|
||||
if csvString != expected {
|
||||
t.Fatalf("expected:\n%s\ngot:\n%s\n", expected, csvString)
|
||||
}
|
||||
tr = c.QueryGRPC(t, indexName, "Row(f1=R1)")
|
||||
csvString, err = tableResponseToCSVString(tr)
|
||||
if err != nil {
|
||||
t.Fatalf("converting to CSV: %v", err)
|
||||
}
|
||||
expected = `
|
||||
`[1:],
|
||||
},
|
||||
{
|
||||
query: "Row(f1=R1)",
|
||||
expected: `
|
||||
_id
|
||||
C1
|
||||
C3
|
||||
|
|
@ -1120,9 +1115,24 @@ C2
|
|||
C5
|
||||
C4
|
||||
C6
|
||||
`[1:]
|
||||
if csvString != expected {
|
||||
t.Fatalf("expected:\n%s\ngot:\n%s\n", expected, csvString)
|
||||
`[1:],
|
||||
},
|
||||
{
|
||||
query: "Row(f1=R1, to='2022-01-09')",
|
||||
expected: "\n",
|
||||
},
|
||||
}
|
||||
|
||||
for i, tst := range tests {
|
||||
tr := c.QueryGRPC(t, indexName, tst.query)
|
||||
csvString, err := tableResponseToCSVString(tr)
|
||||
if err != nil {
|
||||
t.Fatalf("test: %d, converting to CSV: %v", i, err)
|
||||
}
|
||||
// check that an unqualified query does use the standard view
|
||||
if csvString != tst.expected {
|
||||
t.Fatalf("%d expected:\n'%s'\ngot:\n'%s'\n", i, tst.expected, csvString)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -940,6 +940,7 @@ func TestFieldViewsByTimeRange(t *testing.T) {
|
|||
{"2021-01-01T00:00", "2022-01-01T00:00", []string{"standard_2021"}},
|
||||
{"2021-01-01T00:00", "2022-01-02T00:00", []string{"standard_2021", "standard_20220101"}},
|
||||
{"", "2022-01-02T00:00", []string{"standard_2021", "standard_20220101"}},
|
||||
{"", "2020-01-02T00:00", []string{}},
|
||||
{"2021-12-01T00:00", "", []string{"standard_202112", "standard_2022"}},
|
||||
{"2021-12-30T00:00", "2022-02-01T00:00", []string{"standard_20211230", "standard_20211231", "standard_202201"}},
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue