github.com/vmware/govmomi@v0.51.0/ovf/importer/importer_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 importer 6 7 import ( 8 "runtime" 9 "testing" 10 ) 11 12 func TestImporter_manifestPath(t *testing.T) { 13 // We can only test filepath operations on the target OS 14 manifestTests := []struct { 15 goos string 16 name string 17 path string 18 expected string 19 }{ 20 { 21 goos: "linux", 22 name: "linux path", 23 path: "/home/user/foo/bar/qux.ovf", 24 expected: "/home/user/foo/bar/qux.mf", 25 }, 26 { 27 goos: "darwin", 28 name: "darwin path", 29 path: "/home/user/foo/bar/qux.ovf", 30 expected: "/home/user/foo/bar/qux.mf", 31 }, 32 { 33 goos: "windows", 34 name: "windows path", 35 path: "C:\\ProgramData\\Foo\\Bar\\Qux.ovf", 36 expected: "C:\\ProgramData\\Foo\\Bar\\Qux.mf", 37 }, 38 } 39 40 imp := Importer{} 41 42 for _, test := range manifestTests { 43 if test.goos == runtime.GOOS { 44 manifestPath := imp.manifestPath(test.path) 45 if manifestPath != test.expected { 46 t.Fatalf("'%s' failed: expected '%s', got '%s'", test.name, test.expected, manifestPath) 47 } 48 } 49 } 50 }