Skip to content

Commit 92499f8

Browse files
committed
Add test
1 parent a251b9c commit 92499f8

File tree

1 file changed

+27
-2
lines changed

1 file changed

+27
-2
lines changed

Diff for: upload/upload_test.go

+27-2
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ var TestResolveData = []struct {
6666
{"arduino:avr:leonardo",
6767
"./upload_test.hex",
6868
"",
69-
`{runtime.tools.avrdude.path}/bin/avrdude -C{runtime.tools.avrdude.path}/etc/avrdude.conf -v {upload.verify} -patmega32u4 -cavr109 -P/dev/ttyACM0 -b57600 -D "-Uflash:w:{build.path}/{build.project_name}.hex:i"`,
69+
`{runtime.tools.avrdude.path}/bin/avrdude -C{runtime.tools.avrdude.path}/etc/avrdude.conf -v {upload.verify} -patmega32u4 -cavr109 -P{serial.port} -b57600 -D "-Uflash:w:{build.path}/{build.project_name}.hex:i"`,
7070
Extra{Use1200bpsTouch: true, WaitForUploadPort: true},
7171
`$loc$loc{runtime.tools.avrdude.path}/bin/avrdude -C{runtime.tools.avrdude.path}/etc/avrdude.conf -v $loc{upload.verify} -patmega32u4 -cavr109 -P$loc{serial.port} -b57600 -D "-Uflash:w:./upload_test.hex:i"`,
7272
},
@@ -81,7 +81,32 @@ var TestResolveData = []struct {
8181

8282
func TestResolve(t *testing.T) {
8383
for _, test := range TestResolveData {
84-
result, _ := upload.PartiallyResolve(test.Board, test.File, test.PlatformPath, test.Commandline, test.Extra, mockTools{})
84+
result, _ := PartiallyResolve(test.Board, test.File, test.PlatformPath, test.Commandline, test.Extra, mockTools{})
85+
if result != test.Result {
86+
t.Error("expected " + test.Result + ", got " + result)
87+
continue
88+
}
89+
}
90+
}
91+
92+
var TestFixupData = []struct {
93+
Port string
94+
Commandline string
95+
Result string
96+
}{
97+
{"/dev/ttyACM0",
98+
`{runtime.tools.avrdude.path}/bin/avrdude -C{runtime.tools.avrdude.path}/etc/avrdude.conf -v {upload.verify} -patmega32u4 -cavr109 -P{serial.port} -b57600 -D "-Uflash:w:{build.path}/{build.project_name}.hex:i"`,
99+
`{runtime.tools.avrdude.path}/bin/avrdude -C{runtime.tools.avrdude.path}/etc/avrdude.conf -v {upload.verify} -patmega32u4 -cavr109 -P/dev/ttyACM0 -b57600 -D "-Uflash:w:{build.path}/{build.project_name}.hex:i"`,
100+
},
101+
{"/dev/cu.usbmodemDC5475C5557C2",
102+
`{runtime.tools.arduino-fwuploader.path}/arduino-fwuploader firmware flash -a {serial.port} -b arduino:renesas_uno:unor4wifi -v --retries 5"`,
103+
`{runtime.tools.arduino-fwuploader.path}/arduino-fwuploader firmware flash -a /dev/cu.usbmodemDC5475C5557C2 -b arduino:renesas_uno:unor4wifi -v --retries 5"`,
104+
},
105+
}
106+
107+
func TestFixupPort(t *testing.T) {
108+
for _, test := range TestFixupData {
109+
result := fixupPort(test.Port, test.Commandline)
85110
if result != test.Result {
86111
t.Error("expected " + test.Result + ", got " + result)
87112
continue

0 commit comments

Comments
 (0)