fs/rc/jobs: ExecuteJob propagate the error returned by function
Without this patch the resulting error is first converted to string and then recreated. This makes it impossible to use the defined error types to figure out the cause of the error, and may result in invalid HTTP status codes. This patch adds a test TestExecuteJobErrorPropagation to validate that the errors are properly propagated.
This commit is contained in:
committed by
Nick Craig-Wood
parent
341d880027
commit
3247e69cf5
@@ -213,6 +213,17 @@ func TestExecuteJob(t *testing.T) {
|
||||
assert.Equal(t, int64(1), id)
|
||||
}
|
||||
|
||||
func TestExecuteJobErrorPropagation(t *testing.T) {
|
||||
jobID = 0
|
||||
|
||||
testErr := errors.New("test error")
|
||||
errorFn := func(ctx context.Context, in rc.Params) (out rc.Params, err error) {
|
||||
return nil, testErr
|
||||
}
|
||||
_, _, err := ExecuteJob(context.Background(), errorFn, rc.Params{})
|
||||
assert.Equal(t, testErr, err)
|
||||
}
|
||||
|
||||
func TestRcJobStatus(t *testing.T) {
|
||||
jobID = 0
|
||||
_, err := StartAsyncJob(longFn, rc.Params{})
|
||||
|
||||
Reference in New Issue
Block a user