Merged in feature/client (pull request #31)
Client Entity * repolevel * servicefunctions * openapiclientget * openapiupdate * client * vendor
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
package repository_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"path"
|
||||
"queryorchestration/internal/database"
|
||||
"queryorchestration/internal/database/repository"
|
||||
"queryorchestration/internal/test"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestClient(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
db, cleanup := test.CreateDB(t, ctx, &test.CreateDatabaseConfig{
|
||||
Migrations: &database.MigrationConfig{
|
||||
BasePath: path.Join(os.Getenv("PWD"), "../../.."),
|
||||
}})
|
||||
defer cleanup()
|
||||
|
||||
queries := repository.New(db.Pool)
|
||||
|
||||
id, err := queries.CreateClient(ctx, "example_client")
|
||||
assert.Nil(t, err)
|
||||
assert.NotEmpty(t, id)
|
||||
|
||||
client, err := queries.GetClient(ctx, id)
|
||||
assert.Nil(t, err)
|
||||
assert.EqualExportedValues(t, &repository.Client{
|
||||
ID: id,
|
||||
Name: "example_client",
|
||||
Cansync: false,
|
||||
}, client)
|
||||
|
||||
err = queries.UpdateClient(ctx, &repository.UpdateClientParams{
|
||||
ID: id,
|
||||
Name: "updated_client",
|
||||
Cansync: true,
|
||||
})
|
||||
assert.Nil(t, err)
|
||||
|
||||
client, err = queries.GetClient(ctx, id)
|
||||
assert.Nil(t, err)
|
||||
assert.EqualExportedValues(t, &repository.Client{
|
||||
ID: id,
|
||||
Name: "updated_client",
|
||||
Cansync: true,
|
||||
}, client)
|
||||
}
|
||||
Reference in New Issue
Block a user