Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions cmd/dbos/cli_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
_ "github.com/jackc/pgx/v5/stdlib"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.uber.org/goleak"
)

//go:embed cli_test_app.go.test
Expand Down Expand Up @@ -51,6 +52,11 @@ func getDatabaseURL() string {

// TestCLIWorkflow provides comprehensive integration testing of the DBOS CLI
func TestCLIWorkflow(t *testing.T) {
defer goleak.VerifyNone(t,
goleak.IgnoreAnyFunction("github.com/jackc/pgx/v5/pgxpool.(*Pool).backgroundHealthCheck"),
goleak.IgnoreAnyFunction("github.com/jackc/pgx/v5/pgxpool.(*Pool).triggerHealthCheck"),
goleak.IgnoreAnyFunction("github.com/jackc/pgx/v5/pgxpool.(*Pool).triggerHealthCheck.func1"),
)
// Build the CLI once at the beginning
cliPath := buildCLI(t)
t.Logf("Built CLI at: %s", cliPath)
Expand Down
6 changes: 6 additions & 0 deletions dbos/admin_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,15 @@ import (

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.uber.org/goleak"
)

func TestAdminServer(t *testing.T) {
defer goleak.VerifyNone(t,
goleak.IgnoreAnyFunction("github.com/jackc/pgx/v5/pgxpool.(*Pool).backgroundHealthCheck"),
goleak.IgnoreAnyFunction("github.com/jackc/pgx/v5/pgxpool.(*Pool).triggerHealthCheck"),
goleak.IgnoreAnyFunction("github.com/jackc/pgx/v5/pgxpool.(*Pool).triggerHealthCheck.func1"),
)
databaseURL := getDatabaseURL()

t.Run("Admin server is not started by default", func(t *testing.T) {
Expand Down
16 changes: 16 additions & 0 deletions dbos/dbos_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,15 @@ import (
"github.com/jackc/pgx/v5/pgxpool"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.uber.org/goleak"
)

func TestConfig(t *testing.T) {
defer goleak.VerifyNone(t,
goleak.IgnoreAnyFunction("github.com/jackc/pgx/v5/pgxpool.(*Pool).backgroundHealthCheck"),
goleak.IgnoreAnyFunction("github.com/jackc/pgx/v5/pgxpool.(*Pool).triggerHealthCheck"),
goleak.IgnoreAnyFunction("github.com/jackc/pgx/v5/pgxpool.(*Pool).triggerHealthCheck.func1"),
)
databaseURL := getDatabaseURL()

t.Run("CreatesDBOSContext", func(t *testing.T) {
Expand Down Expand Up @@ -275,6 +281,11 @@ func TestConfig(t *testing.T) {
}

func TestCustomSystemDBSchema(t *testing.T) {
defer goleak.VerifyNone(t,
goleak.IgnoreAnyFunction("github.com/jackc/pgx/v5/pgxpool.(*Pool).backgroundHealthCheck"),
goleak.IgnoreAnyFunction("github.com/jackc/pgx/v5/pgxpool.(*Pool).triggerHealthCheck"),
goleak.IgnoreAnyFunction("github.com/jackc/pgx/v5/pgxpool.(*Pool).triggerHealthCheck.func1"),
)
t.Setenv("DBOS__APPVERSION", "v1.0.0")
t.Setenv("DBOS__APPID", "test-custom-schema")
t.Setenv("DBOS__VMID", "test-executor-id")
Expand Down Expand Up @@ -464,6 +475,11 @@ func TestCustomSystemDBSchema(t *testing.T) {
}

func TestCustomPool(t *testing.T) {
defer goleak.VerifyNone(t,
goleak.IgnoreAnyFunction("github.com/jackc/pgx/v5/pgxpool.(*Pool).backgroundHealthCheck"),
goleak.IgnoreAnyFunction("github.com/jackc/pgx/v5/pgxpool.(*Pool).triggerHealthCheck"),
goleak.IgnoreAnyFunction("github.com/jackc/pgx/v5/pgxpool.(*Pool).triggerHealthCheck.func1"),
)
// Test workflows for custom pool testing
type customPoolWorkflowInput struct {
PartnerWorkflowID string
Expand Down
6 changes: 6 additions & 0 deletions dbos/logger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,15 @@ import (

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.uber.org/goleak"
)

func TestLogger(t *testing.T) {
defer goleak.VerifyNone(t,
goleak.IgnoreAnyFunction("github.com/jackc/pgx/v5/pgxpool.(*Pool).backgroundHealthCheck"),
goleak.IgnoreAnyFunction("github.com/jackc/pgx/v5/pgxpool.(*Pool).triggerHealthCheck"),
goleak.IgnoreAnyFunction("github.com/jackc/pgx/v5/pgxpool.(*Pool).triggerHealthCheck.func1"),
)
databaseURL := getDatabaseURL()

t.Run("Default logger", func(t *testing.T) {
Expand Down
8 changes: 4 additions & 4 deletions dbos/workflows_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ func TestWorkflowsRegistration(t *testing.T) {

t.Run("DoubleRegistrationWithoutName", func(t *testing.T) {
// Create a fresh DBOS context for this test
freshCtx := setupDBOS(t, false, false) // Don't check for leaks and don't reset DB
freshCtx := setupDBOS(t, false, true) // Don't reset DB but do check for leaks

// First registration should work
RegisterWorkflow(freshCtx, simpleWorkflow)
Expand All @@ -302,7 +302,7 @@ func TestWorkflowsRegistration(t *testing.T) {

t.Run("DoubleRegistrationWithCustomName", func(t *testing.T) {
// Create a fresh DBOS context for this test
freshCtx := setupDBOS(t, false, false) // Don't check for leaks and don't reset DB
freshCtx := setupDBOS(t, false, true) // Don't reset DB but do check for leaks

// First registration with custom name should work
RegisterWorkflow(freshCtx, simpleWorkflow, WithWorkflowName("custom-workflow"))
Expand All @@ -320,7 +320,7 @@ func TestWorkflowsRegistration(t *testing.T) {

t.Run("DifferentWorkflowsSameCustomName", func(t *testing.T) {
// Create a fresh DBOS context for this test
freshCtx := setupDBOS(t, false, false) // Don't check for leaks and don't reset DB
freshCtx := setupDBOS(t, false, true) // Don't reset DB but do check for leaks

// First registration with custom name should work
RegisterWorkflow(freshCtx, simpleWorkflow, WithWorkflowName("same-name"))
Expand All @@ -338,7 +338,7 @@ func TestWorkflowsRegistration(t *testing.T) {

t.Run("RegisterAfterLaunchPanics", func(t *testing.T) {
// Create a fresh DBOS context for this test
freshCtx := setupDBOS(t, false, false) // Don't check for leaks and don't reset DB
freshCtx := setupDBOS(t, false, true) // Don't reset DB but do check for leaks

// Launch DBOS context
err := freshCtx.Launch()
Expand Down
2 changes: 2 additions & 0 deletions integration/mocks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (

"github.com/dbos-inc/dbos-transact-golang/dbos"
"github.com/stretchr/testify/mock"
"go.uber.org/goleak"
)

func step(ctx context.Context) (int, error) {
Expand Down Expand Up @@ -142,6 +143,7 @@ func aRealProgramFunction(dbosCtx dbos.DBOSContext) error {
}

func TestMocks(t *testing.T) {
defer goleak.VerifyNone(t)
mockCtx := mocks.NewMockDBOSContext(t)

// Context lifecycle
Expand Down
Loading