Files
query-orchestration/internal/database/repository/job_test.go
T
Michael McGuinness 24a038ec3d Merged in feature/doctextstructure (pull request #56)
DocTextRunner Structure

* firstround

* shorttests
2025-02-07 14:15:06 +00:00

61 lines
1.3 KiB
Go

package repository_test
import (
"context"
"os"
"path"
"queryorchestration/internal/database/repository"
"queryorchestration/internal/serviceconfig"
"queryorchestration/internal/test"
"testing"
"github.com/stretchr/testify/assert"
)
func TestJob(t *testing.T) {
if testing.Short() {
t.Skip("Skipping long test in short mode")
}
ctx := context.Background()
cfg := &serviceconfig.BaseConfig{}
test.SetCfgProvider(t, cfg)
cfg.SetBasePath(path.Join(os.Getenv("PWD"), "../../.."))
_, cleanup := test.CreateDB(t, ctx, &test.CreateDatabaseConfig{
Cfg: cfg,
RunMigrations: true,
})
defer cleanup()
queries := cfg.GetDBQueries()
clientId, err := queries.CreateClient(ctx, "example_client")
assert.NoError(t, err)
id, err := queries.CreateJob(ctx, clientId)
assert.NoError(t, err)
assert.NotEmpty(t, id)
job, err := queries.GetJob(ctx, id)
assert.NoError(t, err)
assert.EqualExportedValues(t, &repository.GetJobRow{
ID: id,
Clientid: clientId,
Cansync: false,
}, job)
err = queries.AddJobCanSync(ctx, &repository.AddJobCanSyncParams{
Cansync: true,
Jobid: id,
})
assert.NoError(t, err)
job, err = queries.GetJob(ctx, id)
assert.NoError(t, err)
assert.EqualExportedValues(t, &repository.GetJobRow{
ID: id,
Clientid: clientId,
Cansync: true,
}, job)
}