@@ -43,22 +43,46 @@ func TestWorkflowRuntime(t *testing.T) {
4343 t .Run ("register workflow" , func (t * testing.T ) {
4444 err := testWorker .RegisterWorkflow (testWorkflow )
4545 require .NoError (t , err )
46+
47+ t .Run ("with explicit name" , func (t * testing.T ) {
48+ err := testWorker .RegisterWorkflow (testWorkflow , RegisterWithName ("MyWorkflow" ))
49+ require .NoError (t , err )
50+ })
4651 })
4752 t .Run ("register workflow - anonymous func" , func (t * testing.T ) {
4853 err := testWorker .RegisterWorkflow (func (ctx * WorkflowContext ) (any , error ) {
4954 return nil , nil
5055 })
5156 require .Error (t , err )
57+
58+ t .Run ("with explicit name" , func (t * testing.T ) {
59+ err := testWorker .RegisterWorkflow (func (ctx * WorkflowContext ) (any , error ) {
60+ return nil , nil
61+ }, RegisterWithName ("MyWorkflow2" ))
62+ require .NoError (t , err )
63+ })
5264 })
5365 t .Run ("register activity" , func (t * testing.T ) {
5466 err := testWorker .RegisterActivity (testActivity )
5567 require .NoError (t , err )
68+
69+ t .Run ("with explicit name" , func (t * testing.T ) {
70+ err := testWorker .RegisterActivity (testActivity , RegisterWithName ("MyActivity" ))
71+ require .NoError (t , err )
72+ })
5673 })
5774 t .Run ("register activity - anonymous func" , func (t * testing.T ) {
5875 err := testWorker .RegisterActivity (func (ctx ActivityContext ) (any , error ) {
5976 return nil , nil
6077 })
6178 require .Error (t , err )
79+
80+ t .Run ("with explicit name" , func (t * testing.T ) {
81+ err := testWorker .RegisterActivity (func (ctx ActivityContext ) (any , error ) {
82+ return nil , nil
83+ }, RegisterWithName ("MyActivity2" ))
84+ require .NoError (t , err )
85+ })
6286 })
6387}
6488
@@ -69,6 +93,16 @@ func TestWorkerOptions(t *testing.T) {
6993 })
7094}
7195
96+ func TestRegisterOptions (t * testing.T ) {
97+ t .Run ("with name" , func (t * testing.T ) {
98+ defaultOpts := registerOptions {}
99+ options , err := processRegisterOptions (defaultOpts , RegisterWithName ("testWorkflow" ))
100+ require .NoError (t , err )
101+ assert .NotEmpty (t , options .Name )
102+ assert .Equal (t , "testWorkflow" , options .Name )
103+ })
104+ }
105+
72106func returnWorkerOptions (opts ... workerOption ) workerOptions {
73107 options := new (workerOptions )
74108 for _ , configure := range opts {
@@ -104,6 +138,12 @@ func TestGetFunctionName(t *testing.T) {
104138 require .Error (t , err )
105139 assert .Equal (t , "" , name )
106140 })
141+
142+ t .Run ("get function name - anonymous" , func (t * testing.T ) {
143+ name , err := getFunctionName (func () {})
144+ require .Error (t , err )
145+ assert .Equal (t , "" , name )
146+ })
107147}
108148
109149func testWorkflow (ctx * WorkflowContext ) (any , error ) {
0 commit comments