Skip to content

Commit 74f8203

Browse files
committed
tweaks for coverage
1 parent 638e0e1 commit 74f8203

File tree

3 files changed

+13
-17
lines changed

3 files changed

+13
-17
lines changed

job.go

-11
Original file line numberDiff line numberDiff line change
@@ -158,12 +158,6 @@ func StepAfter[T, S any](bCtx context.Context, j *Job, stepName string, parentSt
158158
}
159159
}
160160

161-
// if a step have no preceding tasks, link it to our rootJob as preceding task, so it won't start yet.
162-
if len(precedingTasks) == 0 {
163-
precedingSteps = append(precedingSteps, j.rootStep)
164-
precedingTasks = append(precedingTasks, j.rootStep.Waitable())
165-
}
166-
167161
// instrument to :
168162
// replaceRuntimeContext
169163
// trackStepState
@@ -221,11 +215,6 @@ func StepAfterBoth[T, S, R any](bCtx context.Context, j *Job, stepName string, p
221215
}
222216
}
223217

224-
// if a step have no preceding tasks, link it to our rootJob as preceding task, so it won't start yet.
225-
if len(precedingTasks) == 0 {
226-
precedingSteps = append(precedingSteps, j.rootStep)
227-
precedingTasks = append(precedingTasks, j.rootStep.Waitable())
228-
}
229218
// instrument to :
230219
// replaceRuntimeContext
231220
// trackStepState

job_test.go

+8-6
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package asyncjob
33
import (
44
"context"
55
"fmt"
6+
"github.com/Azure/go-asynctask"
67
"testing"
78
)
89

@@ -56,19 +57,20 @@ func (sjb *SqlJobBuilder) BuildJob(bCtx context.Context, errorInjections map[str
5657
job := NewJob("sqlSummaryJob")
5758
jobLib := &SqlSummaryJobLib{ErrorInjection: errorInjections}
5859

59-
serverNameParamTask := InputParam(bCtx, job, "param_serverName", &sjb.ServerName)
60+
serverNameParamTask := InputParam(bCtx, job, "serverName", &sjb.ServerName)
6061
connTsk, _ := StepAfter(bCtx, job, "getConnection", serverNameParamTask, jobLib.GetConnection)
6162

62-
table1ParamTsk := InputParam(bCtx, job, "param_table1", &sjb.Table1)
63+
table1ParamTsk := InputParam(bCtx, job, "table1", &sjb.Table1)
6364
table1ClientTsk, _ := StepAfterBoth(bCtx, job, "getTableClient1", connTsk, table1ParamTsk, jobLib.GetTableClient)
64-
query1ParamTsk := InputParam(bCtx, job, "param_query1", &sjb.Query1)
65+
query1ParamTsk := InputParam(bCtx, job, "query1", &sjb.Query1)
6566
qery1ResultTsk, _ := StepAfterBoth(bCtx, job, "queryTable1", table1ClientTsk, query1ParamTsk, jobLib.ExecuteQuery)
6667

67-
table2ParamTsk := InputParam(bCtx, job, "param_table2", &sjb.Table2)
68+
table2ParamTsk := InputParam(bCtx, job, "table2", &sjb.Table2)
6869
table2ClientTsk, _ := StepAfterBoth(bCtx, job, "getTableClient2", connTsk, table2ParamTsk, jobLib.GetTableClient)
69-
query2ParamTsk := InputParam(bCtx, job, "param_query2", &sjb.Query2)
70+
query2ParamTsk := InputParam(bCtx, job, "query2", &sjb.Query2)
7071
qery2ResultTsk, _ := StepAfterBoth(bCtx, job, "queryTable2", table2ClientTsk, query2ParamTsk, jobLib.ExecuteQuery)
7172

72-
StepAfterBoth(bCtx, job, "summarize", qery1ResultTsk, qery2ResultTsk, jobLib.SummarizeQueryResult)
73+
summaryTsk, _ := StepAfterBoth(bCtx, job, "summarize", qery1ResultTsk, qery2ResultTsk, jobLib.SummarizeQueryResult)
74+
AddStep(bCtx, job, "emailNotification", asynctask.ActionToFunc(jobLib.EmailNotification), ExecuteAfter(summaryTsk))
7375
return job
7476
}

sqljob_lib_test.go

+5
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,8 @@ func (sql *SqlSummaryJobLib) SummarizeQueryResult(ctx context.Context, result1 *
5151
fmt.Println("SummarizeQueryResult")
5252
return &SummarizedResult{Data1: result1.Data, Data2: result2.Data}, nil
5353
}
54+
55+
func (sql *SqlSummaryJobLib) EmailNotification(ctx context.Context) error {
56+
fmt.Println("EmailNotification")
57+
return nil
58+
}

0 commit comments

Comments
 (0)