Files
query-orchestration/internal/database/repository/document_test.go
T
Jay Brown 15adaebfcd Merged in feature/serviceconfig-integration (pull request #38)
DRAFT PR : WIP working through ideas for integration

* movearound

* attempttwo

* openapi

* further sanding

* fix

* start on tests

* runthroughsingleconfig

* somechanges

* reflectissue

* removeerrs

* mostlyremovepanic

* removeenv

* noncfgtests

* go

* repo

* fix service config test

* add PWD to all

* test fix

* fix lint

* todo for later

* passingunittests

* alltests

* testlogger

* testloggername

* clean
2025-01-31 13:43:55 +00:00

52 lines
1.1 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 TestDocument(t *testing.T) {
ctx := context.Background()
t.Setenv("BASE_PATH", path.Join(os.Getenv("PWD"), "../../.."))
cfg := &serviceconfig.BaseConfig{}
err := serviceconfig.InitializeConfig(cfg)
assert.Nil(t, err)
_, cleanup := test.CreateDB(t, ctx, &test.CreateDatabaseConfig{
Cfg: cfg,
RunMigrations: true,
})
defer cleanup()
queries := cfg.DBQueries
clientId, err := queries.CreateClient(ctx, "example_client")
assert.Nil(t, err)
jobId, err := queries.CreateJob(ctx, clientId)
assert.Nil(t, err)
hash := "example_hash"
id, err := queries.CreateDocument(ctx, &repository.CreateDocumentParams{
Jobid: jobId,
Hash: hash,
})
assert.Nil(t, err)
assert.NotEmpty(t, id)
doc, err := queries.GetDocument(ctx, id)
assert.Nil(t, err)
assert.EqualExportedValues(t, &repository.Document{
ID: id,
Jobid: jobId,
Hash: hash,
}, doc)
}