github.com/jerryclinesmith/packer@v0.3.7/packer_test.go (about) 1 package main 2 3 import ( 4 "reflect" 5 "testing" 6 ) 7 8 func TestExtractMachineReadable(t *testing.T) { 9 var args, expected, result []string 10 var mr bool 11 12 // Not 13 args = []string{"foo", "bar", "baz"} 14 result, mr = extractMachineReadable(args) 15 expected = []string{"foo", "bar", "baz"} 16 if !reflect.DeepEqual(result, expected) { 17 t.Fatalf("bad: %#v", result) 18 } 19 20 if mr { 21 t.Fatal("should not be mr") 22 } 23 24 // Yes 25 args = []string{"foo", "-machine-readable", "baz"} 26 result, mr = extractMachineReadable(args) 27 expected = []string{"foo", "baz"} 28 if !reflect.DeepEqual(result, expected) { 29 t.Fatalf("bad: %#v", result) 30 } 31 32 if !mr { 33 t.Fatal("should be mr") 34 } 35 }