Skip to content

Commit 03cb9a4

Browse files
committed
cleanup
1 parent 0d9df4e commit 03cb9a4

File tree

3 files changed

+1
-177
lines changed

3 files changed

+1
-177
lines changed

dbos/serialization_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ func testWorkflowRecovery[T any](
307307
// Readability helpers: group related subtests behind concise functions
308308
func runScalarsTests(t *testing.T, executor DBOSContext) {
309309
t.Run("Scalars", func(t *testing.T) {
310-
// Test int as representative scalar type - tests our encode/decode logic, not JSON itself
310+
// Test int as representative scalar type
311311
// Test with any-typed workflow
312312
h1, err := RunWorkflow(executor, serializerAnyValueWorkflow, any(int(42)))
313313
require.NoError(t, err)
@@ -499,7 +499,6 @@ func runJSONEdgeTests(t *testing.T, executor DBOSContext) {
499499
})
500500
}
501501

502-
// Types for additional coverage
503502
type MyInt int
504503
type MyString string
505504

dbos/system_database.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1246,7 +1246,6 @@ func (s *sysDB) recordOperationResult(ctx context.Context, input recordOperation
12461246

12471247
if err != nil {
12481248
if pgErr, ok := err.(*pgconn.PgError); ok && pgErr.Code == _PG_ERROR_UNIQUE_VIOLATION {
1249-
fmt.Println("Conflict error while recording operation result")
12501249
return newWorkflowConflictIDError(input.workflowID)
12511250
}
12521251
return err

dbos/workflows_test.go

Lines changed: 0 additions & 174 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"fmt"
77
"reflect"
88
"runtime"
9-
"strings"
109
"sync"
1110
"sync/atomic"
1211
"testing"
@@ -363,177 +362,6 @@ func TestWorkflowsRegistration(t *testing.T) {
363362
}()
364363
RegisterWorkflow(freshCtx, simpleWorkflow)
365364
})
366-
367-
t.Run("SafeGobRegister", func(t *testing.T) {
368-
// Create a fresh DBOS context for this test
369-
freshCtx := setupDBOS(t, false, true, nil) // Don't reset DB but do check for leaks
370-
371-
// Test 1: Basic type vs pointer conflicts
372-
type TestType struct {
373-
Value string
374-
}
375-
376-
// Register workflows that use the same type to trigger potential gob conflicts
377-
// The safeGobRegister calls within RegisterWorkflow should handle the conflicts
378-
workflow1 := func(ctx DBOSContext, input TestType) (TestType, error) {
379-
return input, nil
380-
}
381-
workflow2 := func(ctx DBOSContext, input *TestType) (*TestType, error) {
382-
return input, nil
383-
}
384-
385-
// Both registrations should succeed despite using conflicting types (T and *T)
386-
RegisterWorkflow(freshCtx, workflow1)
387-
RegisterWorkflow(freshCtx, workflow2)
388-
389-
// Test 2: Multiple workflows with the same types (duplicate registrations)
390-
workflow3 := func(ctx DBOSContext, input TestType) (TestType, error) {
391-
return TestType{Value: input.Value + "-modified"}, nil
392-
}
393-
workflow4 := func(ctx DBOSContext, input TestType) (TestType, error) {
394-
return TestType{Value: input.Value + "-another"}, nil
395-
}
396-
397-
// These should succeed even though TestType is already registered
398-
RegisterWorkflow(freshCtx, workflow3)
399-
RegisterWorkflow(freshCtx, workflow4)
400-
401-
// Test 3: Nested structs
402-
type InnerType struct {
403-
ID int
404-
}
405-
type OuterType struct {
406-
Inner InnerType
407-
Name string
408-
}
409-
410-
workflow5 := func(ctx DBOSContext, input OuterType) (OuterType, error) {
411-
return input, nil
412-
}
413-
workflow6 := func(ctx DBOSContext, input *OuterType) (*OuterType, error) {
414-
return input, nil
415-
}
416-
417-
RegisterWorkflow(freshCtx, workflow5)
418-
RegisterWorkflow(freshCtx, workflow6)
419-
420-
// Test 4: Slice and map types
421-
workflow7 := func(ctx DBOSContext, input []TestType) ([]TestType, error) {
422-
return input, nil
423-
}
424-
workflow8 := func(ctx DBOSContext, input []*TestType) ([]*TestType, error) {
425-
return input, nil
426-
}
427-
workflow9 := func(ctx DBOSContext, input map[string]TestType) (map[string]TestType, error) {
428-
return input, nil
429-
}
430-
workflow10 := func(ctx DBOSContext, input map[string]*TestType) (map[string]*TestType, error) {
431-
return input, nil
432-
}
433-
434-
RegisterWorkflow(freshCtx, workflow7)
435-
RegisterWorkflow(freshCtx, workflow8)
436-
RegisterWorkflow(freshCtx, workflow9)
437-
RegisterWorkflow(freshCtx, workflow10)
438-
439-
// Launch and verify the system still works
440-
err := Launch(freshCtx)
441-
require.NoError(t, err, "failed to launch DBOS after gob conflict handling")
442-
defer Shutdown(freshCtx, 10*time.Second)
443-
444-
// Test all registered workflows to ensure they work correctly
445-
446-
// Run workflow1 with value type
447-
testValue := TestType{Value: "test"}
448-
handle1, err := RunWorkflow(freshCtx, workflow1, testValue)
449-
require.NoError(t, err, "failed to run workflow1")
450-
result1, err := handle1.GetResult()
451-
require.NoError(t, err, "failed to get result from workflow1")
452-
assert.Equal(t, testValue, result1, "unexpected result from workflow1")
453-
454-
// Run workflow2 with pointer type
455-
testPointer := &TestType{Value: "pointer"}
456-
handle2, err := RunWorkflow(freshCtx, workflow2, testPointer)
457-
require.NoError(t, err, "failed to run workflow2")
458-
result2, err := handle2.GetResult()
459-
require.NoError(t, err, "failed to get result from workflow2")
460-
assert.Equal(t, testPointer, result2, "unexpected result from workflow2")
461-
462-
// Run workflow3 with modified output
463-
handle3, err := RunWorkflow(freshCtx, workflow3, testValue)
464-
require.NoError(t, err, "failed to run workflow3")
465-
result3, err := handle3.GetResult()
466-
require.NoError(t, err, "failed to get result from workflow3")
467-
assert.Equal(t, TestType{Value: "test-modified"}, result3, "unexpected result from workflow3")
468-
469-
// Run workflow5 with nested struct
470-
testOuter := OuterType{Inner: InnerType{ID: 42}, Name: "test"}
471-
handle5, err := RunWorkflow(freshCtx, workflow5, testOuter)
472-
require.NoError(t, err, "failed to run workflow5")
473-
result5, err := handle5.GetResult()
474-
require.NoError(t, err, "failed to get result from workflow5")
475-
assert.Equal(t, testOuter, result5, "unexpected result from workflow5")
476-
477-
// Run workflow6 with nested struct pointer
478-
testOuterPtr := &OuterType{Inner: InnerType{ID: 43}, Name: "test-ptr"}
479-
handle6, err := RunWorkflow(freshCtx, workflow6, testOuterPtr)
480-
require.NoError(t, err, "failed to run workflow6")
481-
result6, err := handle6.GetResult()
482-
require.NoError(t, err, "failed to get result from workflow6")
483-
assert.Equal(t, testOuterPtr, result6, "unexpected result from workflow6")
484-
485-
// Run workflow7 with slice type
486-
testSlice := []TestType{{Value: "a"}, {Value: "b"}}
487-
handle7, err := RunWorkflow(freshCtx, workflow7, testSlice)
488-
require.NoError(t, err, "failed to run workflow7")
489-
result7, err := handle7.GetResult()
490-
require.NoError(t, err, "failed to get result from workflow7")
491-
assert.Equal(t, testSlice, result7, "unexpected result from workflow7")
492-
493-
// Run workflow8 with pointer slice type
494-
testPtrSlice := []*TestType{{Value: "a"}, {Value: "b"}}
495-
handle8, err := RunWorkflow(freshCtx, workflow8, testPtrSlice)
496-
require.NoError(t, err, "failed to run workflow8")
497-
result8, err := handle8.GetResult()
498-
require.NoError(t, err, "failed to get result from workflow8")
499-
assert.Equal(t, testPtrSlice, result8, "unexpected result from workflow8")
500-
501-
// Run workflow9 with map type
502-
testMap := map[string]TestType{"key1": {Value: "value1"}}
503-
handle9, err := RunWorkflow(freshCtx, workflow9, testMap)
504-
require.NoError(t, err, "failed to run workflow9")
505-
result9, err := handle9.GetResult()
506-
require.NoError(t, err, "failed to get result from workflow9")
507-
assert.Equal(t, testMap, result9, "unexpected result from workflow9")
508-
509-
// Run workflow10 with pointer map type
510-
testPtrMap := map[string]*TestType{"key1": {Value: "value1"}}
511-
handle10, err := RunWorkflow(freshCtx, workflow10, testPtrMap)
512-
require.NoError(t, err, "failed to run workflow10")
513-
result10, err := handle10.GetResult()
514-
require.NoError(t, err, "failed to get result from workflow10")
515-
assert.Equal(t, testPtrMap, result10, "unexpected result from workflow10")
516-
517-
t.Run("validPanic", func(t *testing.T) {
518-
// Verify that non-duplicate registration panics are still propagated
519-
workflow11 := func(ctx DBOSContext, input any) (any, error) {
520-
return input, nil
521-
}
522-
523-
// This should panic during registration because interface{} creates a nil value
524-
// which gob.Register cannot handle
525-
defer func() {
526-
r := recover()
527-
require.NotNil(t, r, "expected panic from interface{} registration but got none")
528-
// Verify it's not a duplicate registration error (which would be caught)
529-
if errStr, ok := r.(string); ok {
530-
assert.False(t, strings.Contains(errStr, "gob: registering duplicate"),
531-
"panic should not be a duplicate registration error, got: %v", r)
532-
}
533-
}()
534-
RegisterWorkflow(freshCtx, workflow11) // This should panic
535-
})
536-
})
537365
}
538366

539367
func stepWithinAStep(ctx context.Context) (string, error) {
@@ -845,8 +673,6 @@ func TestSteps(t *testing.T) {
845673
require.NotNil(t, step.Output, "step output should not be nil")
846674
assert.Nil(t, step.Error)
847675

848-
fmt.Println("step.Output", step.Output)
849-
850676
// Deserialize the output from the database to verify proper encoding
851677
// Need to recast to JSON because step.Output is an any type
852678
storedOutput, err := convertJSONToType[StepOutput](step.Output)

0 commit comments

Comments
 (0)