Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
chore(*): rename Batch to Oneshot
Browse files Browse the repository at this point in the history
  • Loading branch information
jonboulle committed Jun 9, 2014
1 parent c28666d commit 2c3ede5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions job/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@ func NewJob(name string, unit unit.Unit) *Job {
}
}

// IsBatch identifies whether the Job is intended to execute once, and, on
// IsOneshot identifies whether the Job is intended to execute once, and, on
// completion, not be migrated around the cluster. This is determined by
// whether the unit file associated with the Job is a Service of type "oneshot".
func (j *Job) IsBatch() bool {
func (j *Job) IsOneshot() bool {
s, ok := j.Unit.Contents["Service"]
if !ok {
return false
Expand Down
18 changes: 9 additions & 9 deletions job/job_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,31 +262,31 @@ X-ConditionMachineID=456
}
}

func TestBatchJob(t *testing.T) {
func TestOneshotJob(t *testing.T) {
ej := NewJob("foo.service", *unit.NewUnit(""))
if ej.IsBatch() {
t.Error("IsBatch() on job without Service section returned true unexpectedly")
if ej.IsOneshot() {
t.Error("IsOneshot() on job without Service section returned true unexpectedly")
}

j := NewJob("bar.service", *unit.NewUnit(`
[Service]
ExecStart=/bin/false`))
if j.IsBatch() {
t.Error("IsBatch() on Service job with no Type returned true unexpectedly")
if j.IsOneshot() {
t.Error("IsOneshot() on Service job with no Type returned true unexpectedly")
}

sj := NewJob("bar.service", *unit.NewUnit(`
[Service]
Type=simple`))
if sj.IsBatch() {
t.Error("IsBatch() on simple job returned true unexpectedly")
if sj.IsOneshot() {
t.Error("IsOneshot() on simple job returned true unexpectedly")
}

bj := NewJob("bar.service", *unit.NewUnit(`
[Service]
Type=oneshot`))
if !bj.IsBatch() {
t.Error("IsBatch() on oneshot job returned false unexpectedly")
if !bj.IsOneshot() {
t.Error("IsOneshot() on oneshot job returned false unexpectedly")
}
}

Expand Down

0 comments on commit 2c3ede5

Please sign in to comment.