7da57058d4
Bugfix/flakydb * init * fixenvvar * fixtest
38 lines
935 B
Go
38 lines
935 B
Go
package repository_test
|
|
|
|
import (
|
|
"context"
|
|
"os"
|
|
"path"
|
|
"queryorchestration/internal/database"
|
|
"queryorchestration/internal/database/repository"
|
|
"queryorchestration/internal/test"
|
|
"testing"
|
|
|
|
"github.com/google/uuid"
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestCollector(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)
|
|
|
|
collectorID := database.MustToDBUUID(uuid.New())
|
|
|
|
collectorQueries, err := queries.GetCollectorQueries(ctx, collectorID)
|
|
assert.Nil(t, err)
|
|
assert.Len(t, collectorQueries, 0)
|
|
assert.ElementsMatch(t, []repository.GetCollectorQueriesRow{}, collectorQueries)
|
|
|
|
jobID := database.MustToDBUUID(uuid.New())
|
|
|
|
_, err = queries.GetCollectorFromJobID(ctx, jobID)
|
|
assert.NotNil(t, err)
|
|
}
|