github.com/vmware/govmomi@v0.51.0/toolbox/vix/protocol_test.go (about) 1 // © Broadcom. All Rights Reserved. 2 // The term “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. 3 // SPDX-License-Identifier: Apache-2.0 4 5 package vix 6 7 import ( 8 "reflect" 9 "testing" 10 ) 11 12 func TestMarshalVixMsgStartProgramRequest(t *testing.T) { 13 requests := []*StartProgramRequest{ 14 {}, 15 { 16 ProgramPath: "/bin/date", 17 }, 18 { 19 ProgramPath: "/bin/date", 20 Arguments: "--date=@2147483647", 21 }, 22 { 23 ProgramPath: "/bin/date", 24 WorkingDir: "/tmp", 25 }, 26 { 27 ProgramPath: "/bin/date", 28 WorkingDir: "/tmp", 29 EnvVars: []string{"FOO=bar"}, 30 }, 31 { 32 ProgramPath: "/bin/date", 33 WorkingDir: "/tmp", 34 EnvVars: []string{"FOO=bar", "BAR=foo"}, 35 }, 36 } 37 38 for i, in := range requests { 39 buf, err := in.MarshalBinary() 40 if err != nil { 41 t.Fatal(err) 42 } 43 44 out := new(StartProgramRequest) 45 46 err = out.UnmarshalBinary(buf) 47 if err != nil { 48 t.Fatal(err) 49 } 50 51 if !reflect.DeepEqual(in, out) { 52 t.Errorf("%d marshal mismatch", i) 53 } 54 } 55 }