|
|
|
@ -51,3 +51,44 @@ func TestFormatRowsInvalidQuery(t *testing.T) {
|
|
|
|
|
_, err = store.db.Query("SELECT count(name), distinct(trade_node) from provinces where region = 'France'")
|
|
|
|
|
assert.Error(t, err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestFormatStringSlice(t *testing.T) {
|
|
|
|
|
tests := []struct {
|
|
|
|
|
name string
|
|
|
|
|
s []string
|
|
|
|
|
want string
|
|
|
|
|
}{
|
|
|
|
|
{
|
|
|
|
|
name: "empty",
|
|
|
|
|
s: []string{},
|
|
|
|
|
want: "",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: "single",
|
|
|
|
|
s: []string{"foo"},
|
|
|
|
|
want: "foo",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: "two",
|
|
|
|
|
s: []string{"foo", "bar"},
|
|
|
|
|
want: "foo and bar",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: "three",
|
|
|
|
|
s: []string{"foo", "bar", "baz"},
|
|
|
|
|
want: "foo, bar and baz",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: "four",
|
|
|
|
|
s: []string{"foo", "bar", "baz", "biz"},
|
|
|
|
|
want: "foo, bar, baz and biz",
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
for _, tt := range tests {
|
|
|
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
|
|
|
if got := FormatStringSlice(tt.s); got != tt.want {
|
|
|
|
|
t.Errorf("FormatStringSlice() = %v, want %v", got, tt.want)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|