Skip to content

Commit

Permalink
test(pkg/integration): show users
Browse files Browse the repository at this point in the history
Signed-off-by: Jeronimo Irazabal <[email protected]>
  • Loading branch information
jeroiraz committed Nov 8, 2023
1 parent 58dfcca commit 932d73f
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
10 changes: 10 additions & 0 deletions embedded/sql/engine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6043,6 +6043,16 @@ func TestMultiDBCatalogQueries(t *testing.T) {
require.NoError(t, err)
})

t.Run("show users", func(t *testing.T) {
r, err := engine.Query(context.Background(), nil, "SHOW USERS", nil)
require.NoError(t, err)

defer r.Close()

_, err = r.Read(context.Background())
require.ErrorIs(t, err, ErrNoMoreRows)
})

t.Run("query databases using conditions with table and column aliasing", func(t *testing.T) {
r, err := engine.Query(context.Background(), nil, "SELECT dbs.name as dbname FROM DATABASES() as dbs WHERE name LIKE 'db*'", nil)
require.NoError(t, err)
Expand Down
17 changes: 17 additions & 0 deletions pkg/integration/session_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,3 +197,20 @@ func TestSession_CreateDBFromSQLStmts(t *testing.T) {
err = client.CloseSession(context.Background())
require.NoError(t, err)
}

func TestSession_ListUSersFromSQLStmts(t *testing.T) {
_, client, ctx := setupTestServerAndClient(t)

_, err := client.SQLExec(ctx, "CREATE DATABASE db1", nil)
require.NoError(t, err)

err = client.CreateUser(ctx, []byte("user1"), []byte("user1Password!"), 1, "db1")
require.NoError(t, err)

res, err := client.SQLQuery(ctx, "SHOW USERS", nil, false)
require.NoError(t, err)
require.Len(t, res.Rows, 1)

err = client.CloseSession(context.Background())
require.NoError(t, err)
}

0 comments on commit 932d73f

Please sign in to comment.