func TestWorkerFailure(t *testing.T) {
	tube, id := queueJob("hello world", 10, defaultTtr)
	cmd := "false"
	results := make(chan *JobResult)
	b := New(address, tube, 0, cmd, results)
	ticks := make(chan bool)
	defer close(ticks)
	go b.Run(ticks)
	ticks <- true  
	result := <-results
	if result.JobId != id {
		t.Fatalf("result.JobId %d != queueJob id %d", result.JobId, id)
	}
	if result.ExitStatus != 1 {
		t.Fatalf("result.ExitStatus %d, expected 1", result.ExitStatus)
	}
	assertJobStat(t, id, "state", "ready")
	assertJobStat(t, id, "releases", "1")
	assertJobStat(t, id, "pri", "10")
}
TestWorkerFailure demonstrates a failed exit(1) task (release).
package broker
import (
	"bytes"
	"log"
	"math/rand"
	"strconv"
	"testing"
	"time"
	"github.com/kr/beanstalk"
)
const (
	address    = "127.0.0.1:11300"
	defaultTtr = 10 * time.Second
)
func TestWorkerSuccess(t *testing.T) {
	tube, id := queueJob("hello world", 10, defaultTtr)
	expectStdout := []byte("HELLO WORLD")
	cmd := "tr [a-z] [A-Z]"
	results := make(chan *JobResult)
	b := New(address, tube, 0, cmd, results)
	ticks := make(chan bool)
	defer close(ticks)
	go b.Run(ticks)
	ticks <- true  
	result := <-results
	if result.JobId != id {
		t.Fatalf("result.JobId %d != queueJob id %d", result.JobId, id)
	}
	if !bytes.Equal(result.Stdout, expectStdout) {
		t.Fatalf("Stdout mismatch: '%s' != '%s'\n", result.Stdout, expectStdout)
	}
	if result.ExitStatus != 0 {
		t.Fatalf("Unexpected exit status %d", result.ExitStatus)
	}
	assertTubeEmpty(tube)
}