Skip to content

Commit

Permalink
Fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
xBlaz3kx committed Jul 31, 2024
1 parent 4a77a5b commit 19542a2
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
7 changes: 4 additions & 3 deletions foundation/database/dbtest/dbtest.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"testing"
"time"

"github.com/GLCharge/otelzap"
"github.com/jmoiron/sqlx"
"github.com/xBlaz3kx/distributed-scheduler/foundation/database"
"github.com/xBlaz3kx/distributed-scheduler/foundation/database/dbmigrate"
Expand Down Expand Up @@ -46,7 +47,7 @@ func StopDB(c *docker.Container) {
// Test owns state for running and shutting down tests.
type Test struct {
DB *sqlx.DB
Log *zap.SugaredLogger
Log *otelzap.Logger
Teardown func()
t *testing.T
}
Expand Down Expand Up @@ -114,10 +115,10 @@ func NewTest(t *testing.T, c *docker.Container) *Test {
var buf bytes.Buffer
encoder := zapcore.NewConsoleEncoder(zap.NewDevelopmentEncoderConfig())
writer := bufio.NewWriter(&buf)
log := zap.New(
log := otelzap.New(zap.New(
zapcore.NewCore(encoder, zapcore.AddSync(writer), zapcore.DebugLevel),
zap.WithCaller(true),
).Sugar()
))

t.Log("Ready for testing ...")

Expand Down
11 changes: 6 additions & 5 deletions service/job/job_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ package job
import (
"context"
"fmt"
"runtime/debug"
"testing"
"time"

"github.com/google/go-cmp/cmp"
"github.com/google/uuid"
"github.com/samber/lo"
Expand All @@ -11,9 +15,6 @@ import (
"github.com/xBlaz3kx/distributed-scheduler/model"
"github.com/xBlaz3kx/distributed-scheduler/store/postgres"
"gopkg.in/guregu/null.v4"
"runtime/debug"
"testing"
"time"
)

var c *docker.Container
Expand Down Expand Up @@ -120,7 +121,7 @@ func crud(t *testing.T) {
// Get jobs
// -------------------------------------------------------------------------

jobs, err := jobService.ListJobs(ctx, 10, 0)
jobs, err := jobService.ListJobs(ctx, 10, 0, []string{})
if err != nil {
t.Fatalf("Should be able to list jobs: %s", err)
}
Expand All @@ -132,7 +133,7 @@ func crud(t *testing.T) {
// Get jobs with limit
// -------------------------------------------------------------------------

jobs, err = jobService.ListJobs(ctx, 1, 0)
jobs, err = jobService.ListJobs(ctx, 1, 0, []string{})
if err != nil {
t.Fatalf("Should be able to list jobs: %s", err)
}
Expand Down
1 change: 1 addition & 0 deletions store/postgres/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package postgres

import (
"database/sql"

"github.com/GLCharge/otelzap"
"github.com/jmoiron/sqlx"
"go.uber.org/zap"
Expand Down

0 comments on commit 19542a2

Please sign in to comment.