Makefile: implement make db-tests

enables the option to run the DB tests locally
that are executed in the github actions
This commit is contained in:
Florian Schüller 2024-10-23 14:33:45 +02:00 committed by Florian Schüller
parent 1f8da3bd83
commit 00d3f07d08
8 changed files with 74 additions and 18 deletions

View file

@ -14,12 +14,10 @@ import (
"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)
conn, err := pgx.Connect(context.Background(), jobqueuetest.TestDbURL())
if err != nil {
return nil, nil, err
}
@ -35,7 +33,7 @@ func TestJobQueueInterface(t *testing.T) {
return nil, nil, err
}
q, err := dbjobqueue.New(url)
q, err := dbjobqueue.New(jobqueuetest.TestDbURL())
if err != nil {
return nil, nil, err
}

View file

@ -5,6 +5,7 @@ package main
import (
"context"
"encoding/json"
"github.com/osbuild/osbuild-composer/internal/jobqueue/jobqueuetest"
"testing"
"github.com/google/uuid"
@ -13,13 +14,11 @@ import (
"github.com/osbuild/osbuild-composer/pkg/jobqueue/dbjobqueue"
)
const url = "postgres://postgres:foobar@localhost:5432/osbuildcomposer"
func TestDBJobQueueMaintenance(t *testing.T) {
dbMaintenance, err := newDB(url)
dbMaintenance, err := newDB(jobqueuetest.TestDbURL())
require.NoError(t, err)
defer dbMaintenance.Close()
q, err := dbjobqueue.New(url)
q, err := dbjobqueue.New(jobqueuetest.TestDbURL())
require.NoError(t, err)
defer q.Close()