Files
query-orchestration/internal/client/create_test.go
T
Michael McGuinness ed8cfbbee4 Merged in feature/collectorset (pull request #96)
Set Collector

* set
2025-03-10 13:00:57 +00:00

42 lines
897 B
Go

package client_test
import (
"context"
"testing"
"queryorchestration/internal/client"
"queryorchestration/internal/database"
"queryorchestration/internal/database/repository"
"queryorchestration/internal/serviceconfig"
"github.com/google/uuid"
"github.com/pashagolub/pgxmock/v3"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestCreate(t *testing.T) {
ctx := context.Background()
pool, err := pgxmock.NewPool()
require.NoError(t, err)
cfg := &serviceconfig.BaseConfig{}
cfg.DBPool = pool
cfg.DBQueries = repository.New(pool)
svc := client.New(cfg)
name := "client_name"
aid := uuid.New()
pool.ExpectQuery("name: CreateClient :one").WithArgs(name).
WillReturnRows(
pgxmock.NewRows([]string{"id"}).
AddRow(database.MustToDBUUID(aid)),
)
id, err := svc.Create(ctx, name)
assert.NoError(t, err)
assert.Equal(t, aid, id)
}