29 lines
521 B
Go
29 lines
521 B
Go
package runner
|
|
|
|
import (
|
|
"errors"
|
|
"testing"
|
|
)
|
|
|
|
func TestTaskHasErrorReturnsFalseIfNoUnderlyingJobHaveErrors(t *testing.T) {
|
|
task := NewTask()
|
|
task.AddJob()
|
|
|
|
if task.HasError() {
|
|
t.Errorf("Expected false, got true.")
|
|
}
|
|
}
|
|
|
|
func TestTaskHasErrorReturnsTrueIfAnyJobHasErrors(t *testing.T) {
|
|
task := NewTask()
|
|
|
|
// Two jobs, one of which has an error.
|
|
task.AddJob()
|
|
jobId := task.AddJob()
|
|
|
|
task.GetJobContext(jobId).SetError(errors.New("test"))
|
|
|
|
if !task.HasError() {
|
|
t.Errorf("Expected true, got false.")
|
|
}
|
|
}
|