Skip to content

Commit

Permalink
testing: Return pointer of workflow run for constructor `NewTestingRu…
Browse files Browse the repository at this point in the history
…n` (#91)
  • Loading branch information
andrewwormald authored Feb 11, 2025
1 parent 98deb76 commit d38f95b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion autopause_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func Test_maybeAutoPause(t *testing.T) {
counter,
testErr,
processName,
&r,
r,
&logger{},
)
require.ErrorIs(t, err, tc.expectedErr)
Expand Down
10 changes: 10 additions & 0 deletions run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,13 @@ func TestNewTestingRun(t *testing.T) {
require.Nil(t, err)
require.Equal(t, status(workflow.SkipTypeRunStateUpdate), cancelStatus)
}

func TestNewTestingRun_requiresTestingParam(t *testing.T) {
require.PanicsWithValue(t,
"Cannot use NewTestingRun without *testing.T parameter",
func() {
_ = workflow.NewTestingRun[string, status](nil, workflow.Record{}, "test")
},
)

}
8 changes: 6 additions & 2 deletions testing.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,13 +179,17 @@ func NewTestingRun[Type any, Status StatusType](
wr Record,
object Type,
opts ...TestingRunOption,
) Run[Type, Status] {
) *Run[Type, Status] {
if t == nil {
panic("Cannot use NewTestingRun without *testing.T parameter")
}

var options testingRunOpts
for _, opt := range opts {
opt(&options)
}

return Run[Type, Status]{
return &Run[Type, Status]{
TypedRecord: TypedRecord[Type, Status]{
Record: wr,
Status: Status(wr.Status),
Expand Down

0 comments on commit d38f95b

Please sign in to comment.