debian-forge-composer/cmd/osbuild-composer-dbjobqueue-tests/main_test.go
Brian C. Lane b1c2dbdfc6 Remove old build tag comments
Go is transitioning from the old '// +build' form to '//go:build', this
removes all uses of the old form, adding the new one where needed.

See https://go.googlesource.com/proposal/+/master/design/draft-gobuild.md
2023-03-07 09:22:23 -08:00

49 lines
1.1 KiB
Go

//go:build integration
package main
import (
"context"
"fmt"
"testing"
"github.com/jackc/pgx/v4"
"github.com/osbuild/osbuild-composer/pkg/jobqueue"
"github.com/osbuild/osbuild-composer/pkg/jobqueue/dbjobqueue"
"github.com/osbuild/osbuild-composer/internal/jobqueue/jobqueuetest"
)
const url = "postgres://postgres:foobar@localhost:5432/osbuildcomposer"
func TestJobQueueInterface(t *testing.T) {
makeJobQueue := func() (jobqueue.JobQueue, func(), error) {
// clear db before each run
conn, err := pgx.Connect(context.Background(), url)
if err != nil {
return nil, nil, err
}
defer conn.Close(context.Background())
for _, table := range []string{"job_dependencies", "heartbeats", "jobs"} {
_, err = conn.Exec(context.Background(), fmt.Sprintf("DELETE FROM %s", table))
if err != nil {
return nil, nil, err
}
}
err = conn.Close(context.Background())
if err != nil {
return nil, nil, err
}
q, err := dbjobqueue.New(url)
if err != nil {
return nil, nil, err
}
stop := func() {
q.Close()
}
return q, stop, nil
}
jobqueuetest.TestJobQueue(t, makeJobQueue)
}