-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Victor Vieux <[email protected]>
- Loading branch information
Showing
5 changed files
with
76 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package service | ||
|
||
import ( | ||
"bytes" | ||
"testing" | ||
|
||
"github.com/spf13/pflag" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestWarnDetachDefault(t *testing.T) { | ||
var detach bool | ||
flags := pflag.NewFlagSet("test", pflag.ContinueOnError) | ||
addDetachFlag(flags, &detach) | ||
|
||
var tests = []struct { | ||
detach bool | ||
version string | ||
|
||
expectWarning bool | ||
}{ | ||
{true, "1.28", false}, | ||
{true, "1.29", false}, | ||
{false, "1.28", false}, | ||
{false, "1.29", true}, | ||
} | ||
|
||
for _, test := range tests { | ||
out := new(bytes.Buffer) | ||
flags.Lookup(flagDetach).Changed = test.detach | ||
|
||
warnDetachDefault(out, test.version, flags, "") | ||
|
||
if test.expectWarning { | ||
assert.NotEmpty(t, out.String(), "expected warning") | ||
} else { | ||
assert.Empty(t, out.String(), "expected no warning") | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters