// Aborting a job shall be immediate. func TestJobAbort(t *testing.T) { job := newTestJob(pytest.ReadTask(t, "timeout"), "") done := make(chan bool) go func() { wd := testutils.Watchdog(t, 2) status, output := job.Execute() wd.Stop() testutils.Expect(t, "status", pythia.Abort, status) testutils.Expect(t, "output", "Start\n", output) done <- true }() time.Sleep(1 * time.Second) job.Abort() <-done }
// Test a simple message transfer func TestConnSimpleMessage(t *testing.T) { raw1, raw2 := net.Pipe() c1, c2 := WrapConn(raw1), WrapConn(raw2) msg := Message{Message: DoneMsg, Id: "1"} go c1.Send(msg) received := <-c2.Receive() testutils.Expect(t, "received", msg, received) c1.Close() c2.Close() connTestFlush(t, c2) }
// RunTaskCheck behaves like RunTask, but additionally checks for expected // status and output. func runTaskCheck(t *testing.T, task pythia.Task, input string, status pythia.Status, output string) { st, out := runTask(t, task, input) testutils.Expect(t, "status", status, st) testutils.Expect(t, "output", output, out) }