mirror of https://github.com/VinGarcia/ksql.git
Rename the Get function to Find
This change was made based on a suggestion from Raí Tamarindo (raitamarindo@gmail.com)pull/2/head
parent
67cedb1f81
commit
387c2cdd74
|
@ -19,9 +19,10 @@ func NewClient(tableName string) Client {
|
|||
}
|
||||
}
|
||||
|
||||
// Get one instance from the database, the input struct
|
||||
// must be passed by reference.
|
||||
func (c Client) Get(
|
||||
// Find one instance from the database, the input struct
|
||||
// must be passed by reference and the query should
|
||||
// return only one result.
|
||||
func (c Client) Find(
|
||||
ctx context.Context,
|
||||
item interface{},
|
||||
query string,
|
||||
|
|
|
@ -16,7 +16,7 @@ type User struct {
|
|||
CreatedAt time.Time
|
||||
}
|
||||
|
||||
func TestGet(t *testing.T) {
|
||||
func TestFind(t *testing.T) {
|
||||
err := createTable()
|
||||
if err != nil {
|
||||
t.Fatal("could not create test table!")
|
||||
|
@ -32,7 +32,7 @@ func TestGet(t *testing.T) {
|
|||
tableName: "users",
|
||||
}
|
||||
u := User{}
|
||||
err := c.Get(ctx, &u, `SELECT * FROM users WHERE id=1;`)
|
||||
err := c.Find(ctx, &u, `SELECT * FROM users WHERE id=1;`)
|
||||
assert.Equal(t, err, nil)
|
||||
assert.Equal(t, User{}, u)
|
||||
})
|
||||
|
@ -51,7 +51,7 @@ func TestGet(t *testing.T) {
|
|||
tableName: "users",
|
||||
}
|
||||
u := User{}
|
||||
err = c.Get(ctx, &u, `SELECT * FROM users WHERE name='Bia';`)
|
||||
err = c.Find(ctx, &u, `SELECT * FROM users WHERE name='Bia';`)
|
||||
|
||||
assert.Equal(t, err, nil)
|
||||
assert.Equal(t, "Bia", u.Name)
|
||||
|
|
Loading…
Reference in New Issue