courgette/internal/runner/task_test.go

30 lines
521 B
Go
Raw Normal View History

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.")
}
}