Skip to content

Commit e20f8ef

Browse files
authored
refactor: consolidate testdata paths (#343)
Moved common testdata files from `builder/vmware/iso` and `builder/vmware/vmx` test directories to a shared location under `builder/vmware/common/testdata`. Updated test code to reference the new shared paths, improving maintainability and reducing duplication. Signed-off-by: Ryan Johnson <ryan.johnson@broadcom.com>
1 parent 6612c92 commit e20f8ef

9 files changed

Lines changed: 13 additions & 10 deletions

File tree

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

builder/vmware/iso/builder_acc_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import (
1515
)
1616

1717
func TestBuilderAcc_basic(t *testing.T) {
18-
templatePath := filepath.Join("testdata", "minimal.json")
18+
templatePath := filepath.Join("..", "common", "testdata", "minimal.json")
1919
bytes, err := os.ReadFile(templatePath)
2020
if err != nil {
2121
t.Fatalf("failed to load template file %s", templatePath)

builder/vmware/iso/builder_test.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ package iso
66
import (
77
"fmt"
88
"os"
9+
"path/filepath"
910
"reflect"
1011
"testing"
1112

@@ -106,8 +107,11 @@ func TestBuilderPrepare_FloppyFiles(t *testing.T) {
106107
t.Fatalf("bad: %#v", b.config.FloppyFiles)
107108
}
108109

109-
floppiesPath := "testdata/floppies"
110-
config["floppy_files"] = []string{fmt.Sprintf("%s/bar.bat", floppiesPath), fmt.Sprintf("%s/foo.ps1", floppiesPath)}
110+
floppiesPath := filepath.Join("..", "common", "testdata", "floppies")
111+
config["floppy_files"] = []string{
112+
fmt.Sprintf("%s/bar.bat", floppiesPath),
113+
fmt.Sprintf("%s/foo.ps1", floppiesPath),
114+
}
111115
b = Builder{}
112116
_, warns, err = b.Prepare(config)
113117
if len(warns) > 0 {

builder/vmware/vmx/builder_test.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ package vmx
66
import (
77
"fmt"
88
"os"
9+
"path/filepath"
910
"reflect"
1011
"testing"
1112

@@ -38,8 +39,11 @@ func TestBuilderPrepare_FloppyFiles(t *testing.T) {
3839
t.Fatalf("bad: %#v", b.config.FloppyFiles)
3940
}
4041

41-
floppiesPath := "testdata/floppies"
42-
config["floppy_files"] = []string{fmt.Sprintf("%s/bar.bat", floppiesPath), fmt.Sprintf("%s/foo.ps1", floppiesPath)}
42+
floppiesPath := filepath.Join("..", "common", "testdata", "floppies")
43+
config["floppy_files"] = []string{
44+
fmt.Sprintf("%s/bar.bat", floppiesPath),
45+
fmt.Sprintf("%s/foo.ps1", floppiesPath),
46+
}
4347
b = Builder{}
4448
_, warns, err = b.Prepare(config)
4549
if len(warns) > 0 {

builder/vmware/vmx/testdata/floppies/bar.bat

Lines changed: 0 additions & 1 deletion
This file was deleted.

builder/vmware/vmx/testdata/floppies/foo.ps1

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)