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

Commit

Permalink
fleetctl:test: push tests for getBlockAttempts()
Browse files Browse the repository at this point in the history
  • Loading branch information
Djalal Harouni committed Feb 20, 2016
1 parent 9ba11af commit 75dcaa0
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions fleetctl/fleetctl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,51 @@ func TestUnitNameMangle(t *testing.T) {
}
}

func TestGetBlockAttempts(t *testing.T) {
oldNoBlock := sharedFlags.NoBlock
oldBlockAttempts := sharedFlags.BlockAttempts
sharedFlags.NoBlock = true
sharedFlags.BlockAttempts = 0

if n := getBlockAttempts(); n != -1 {
t.Errorf("got %d, want -1", n)
}

sharedFlags.BlockAttempts = -1
if n := getBlockAttempts(); n != -1 {
t.Errorf("got %d, want -1", n)
}

sharedFlags.BlockAttempts = 9999
if n := getBlockAttempts(); n != -1 {
t.Errorf("got %d, want -1", n)
}

sharedFlags.NoBlock = false
sharedFlags.BlockAttempts = 0
if n := getBlockAttempts(); n != 0 {
t.Errorf("got %d, want 0", n)
}

sharedFlags.BlockAttempts = -1
if n := getBlockAttempts(); n != 0 {
t.Errorf("got %d, want 0", n)
}

sharedFlags.BlockAttempts = 0
if n := getBlockAttempts(); n != 0 {
t.Errorf("got %d, want 0", n)
}

sharedFlags.BlockAttempts = 9999
if n := getBlockAttempts(); n != 9999 {
t.Errorf("got %d, want 9999", n)
}

sharedFlags.NoBlock = oldNoBlock
sharedFlags.BlockAttempts = oldBlockAttempts
}

func newUnitFile(t *testing.T, contents string) *unit.UnitFile {
uf, err := unit.NewUnitFile(contents)
if err != nil {
Expand Down

0 comments on commit 75dcaa0

Please sign in to comment.