Improve a comment and a test

pull/2/head
Vinícius Garcia 2021-04-24 12:15:59 -03:00
parent 99ed52b591
commit d2c88ed71b
2 changed files with 6 additions and 3 deletions

View File

@ -67,7 +67,9 @@ func (builder *Builder) Build(query Query) (sqlQuery string, params []interface{
} }
type Query struct { type Query struct {
// Select expects a struct using the `ksql` tags // Select expects either a struct using the `ksql` tags
// or a string listing the column names using SQL syntax,
// e.g.: `id, username, address`
Select interface{} Select interface{}
// From expects the FROM clause from an SQL query, e.g. `users JOIN posts USING(post_id)` // From expects the FROM clause from an SQL query, e.g. `users JOIN posts USING(post_id)`

View File

@ -4,6 +4,7 @@ import (
"fmt" "fmt"
"testing" "testing"
"github.com/stretchr/testify/require"
"github.com/tj/assert" "github.com/tj/assert"
"github.com/vingarcia/ksql/kbuilder" "github.com/vingarcia/ksql/kbuilder"
) )
@ -137,8 +138,8 @@ func TestBuilder(t *testing.T) {
func expectError(t *testing.T, expect bool, err error) { func expectError(t *testing.T, expect bool, err error) {
if expect { if expect {
assert.Equal(t, true, err != nil, "expected an error, but got nothing") require.Equal(t, true, err != nil, "expected an error, but got nothing")
} else { } else {
assert.Equal(t, false, err != nil, fmt.Sprintf("unexpected error %s", err)) require.Equal(t, false, err != nil, fmt.Sprintf("unexpected error %s", err))
} }
} }