Fix broken whereclause test

This commit is contained in:
Patrick O'brien 2016-08-09 18:11:28 +10:00
parent 33286e648a
commit 3431919269

View file

@ -300,7 +300,6 @@ func TestPrefixStringSlice(t *testing.T) {
t.Error("wrong output:", got) t.Error("wrong output:", got)
} }
} }
func TestWhereClause(t *testing.T) { func TestWhereClause(t *testing.T) {
t.Parallel() t.Parallel()
@ -309,15 +308,15 @@ func TestWhereClause(t *testing.T) {
Start int Start int
Should string Should string
}{ }{
{Cols: []string{"col1", "col2"}, Start: 2, Should: `("col1"=$2 AND "col2"=$3 AND "col1"=$4 AND "col2"=$5)`}, {Cols: []string{"col1"}, Start: 2, Should: `"col1"=$2`},
{Cols: []string{"col1", "col2"}, Start: 4, Should: `("col1"=$4 AND "col2"=$5 AND "col1"=$6 AND "col2"=$7)`}, {Cols: []string{"col1", "col2"}, Start: 4, Should: `"col1"=$4 AND "col2"=$5`},
{Cols: []string{"col1", "col2", "col3"}, Start: 4, Should: `("col1"=$4 AND "col2"=$5 AND "col3"=$6)`}, {Cols: []string{"col1", "col2", "col3"}, Start: 4, Should: `"col1"=$4 AND "col2"=$5 AND "col3"=$6`},
} }
for i, test := range tests { for i, test := range tests {
r := WhereClause(test.Start, test.Cols) r := WhereClause(test.Start, test.Cols)
if r != test.Should { if r != test.Should {
t.Errorf("(%d) want: %s, got: %s", i, test.Should, r) t.Errorf("(%d) want: %s, got: %s\nTest: %#v", i, test.Should, r, test)
} }
} }
} }