mirror of https://github.com/hashicorp/packer
parent
ca54df1a76
commit
f46bf47579
@ -1 +1,35 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestExtractMachineReadable(t *testing.T) {
|
||||
var args, expected, result []string
|
||||
var mr bool
|
||||
|
||||
// Not
|
||||
args = []string{"foo", "bar", "baz"}
|
||||
result, mr = extractMachineReadable(args)
|
||||
expected = []string{"foo", "bar", "baz"}
|
||||
if !reflect.DeepEqual(result, expected) {
|
||||
t.Fatalf("bad: %#v", result)
|
||||
}
|
||||
|
||||
if mr {
|
||||
t.Fatal("should not be mr")
|
||||
}
|
||||
|
||||
// Yes
|
||||
args = []string{"foo", "--machine-readable", "baz"}
|
||||
result, mr = extractMachineReadable(args)
|
||||
expected = []string{"foo", "baz"}
|
||||
if !reflect.DeepEqual(result, expected) {
|
||||
t.Fatalf("bad: %#v", result)
|
||||
}
|
||||
|
||||
if !mr {
|
||||
t.Fatal("should be mr")
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in new issue