Skip to content

Commit d56e8d4

Browse files
committed
Sligthly simplified upload test cases handling
1 parent 439c473 commit d56e8d4

File tree

1 file changed

+19
-22
lines changed

1 file changed

+19
-22
lines changed

Diff for: commands/upload/upload_test.go

+19-22
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ func TestDetermineBuildPathAndSketchName(t *testing.T) {
5555
fqbn *cores.FQBN
5656
resBuildPath string
5757
resSketchName string
58-
hasError bool
5958
}
6059

6160
blonk, err := sketches.NewSketchFromPath(paths.New("testdata/Blonk"))
@@ -66,52 +65,50 @@ func TestDetermineBuildPathAndSketchName(t *testing.T) {
6665

6766
tests := []test{
6867
// 00: error: no data passed in
69-
{"", "", nil, nil, "<nil>", "", true},
68+
{"", "", nil, nil, "<nil>", ""},
7069
// 01: use importFile to detect build.path and project_name
71-
{"testdata/build_path_2/Blink.ino.hex", "", nil, nil, "testdata/build_path_2", "Blink.ino", false},
70+
{"testdata/build_path_2/Blink.ino.hex", "", nil, nil, "testdata/build_path_2", "Blink.ino"},
7271
// 02: use importPath as build.path and project_name
73-
{"", "testdata/build_path_2", nil, nil, "testdata/build_path_2", "Blink.ino", false},
72+
{"", "testdata/build_path_2", nil, nil, "testdata/build_path_2", "Blink.ino"},
7473
// 03: error: used both importPath and importFile
75-
{"testdata/build_path_2/Blink.ino.hex", "testdata/build_path_2", nil, nil, "<nil>", "", true},
74+
{"testdata/build_path_2/Blink.ino.hex", "testdata/build_path_2", nil, nil, "<nil>", ""},
7675
// 04: error: only sketch without FQBN
77-
{"", "", blonk, nil, "<nil>", "", true},
76+
{"", "", blonk, nil, "<nil>", ""},
7877
// 05: use importFile to detect build.path and project_name, sketch is ignored.
79-
{"testdata/build_path_2/Blink.ino.hex", "", blonk, nil, "testdata/build_path_2", "Blink.ino", false},
78+
{"testdata/build_path_2/Blink.ino.hex", "", blonk, nil, "testdata/build_path_2", "Blink.ino"},
8079
// 06: use importPath as build.path and Blink as project name, ignore the sketch Blonk
81-
{"", "testdata/build_path_2", blonk, nil, "testdata/build_path_2", "Blink.ino", false},
80+
{"", "testdata/build_path_2", blonk, nil, "testdata/build_path_2", "Blink.ino"},
8281
// 07: error: used both importPath and importFile
83-
{"testdata/build_path_2/Blink.ino.hex", "testdata/build_path_2", blonk, nil, "<nil>", "", true},
82+
{"testdata/build_path_2/Blink.ino.hex", "testdata/build_path_2", blonk, nil, "<nil>", ""},
8483

8584
// 08: error: no data passed in
86-
{"", "", nil, fqbn, "<nil>", "", true},
85+
{"", "", nil, fqbn, "<nil>", ""},
8786
// 09: use importFile to detect build.path and project_name, fqbn ignored
88-
{"testdata/build_path_2/Blink.ino.hex", "", nil, fqbn, "testdata/build_path_2", "Blink.ino", false},
87+
{"testdata/build_path_2/Blink.ino.hex", "", nil, fqbn, "testdata/build_path_2", "Blink.ino"},
8988
// 10: use importPath as build.path and project_name, fqbn ignored
90-
{"", "testdata/build_path_2", nil, fqbn, "testdata/build_path_2", "Blink.ino", false},
89+
{"", "testdata/build_path_2", nil, fqbn, "testdata/build_path_2", "Blink.ino"},
9190
// 11: error: used both importPath and importFile
92-
{"testdata/build_path_2/Blink.ino.hex", "testdata/build_path_2", nil, fqbn, "<nil>", "", true},
91+
{"testdata/build_path_2/Blink.ino.hex", "testdata/build_path_2", nil, fqbn, "<nil>", ""},
9392
// 12: use sketch to determine project name and sketch+fqbn to determine build path
94-
{"", "", blonk, fqbn, "testdata/Blonk/build/arduino.samd.mkr1000", "Blonk.ino", false},
93+
{"", "", blonk, fqbn, "testdata/Blonk/build/arduino.samd.mkr1000", "Blonk.ino"},
9594
// 13: use importFile to detect build.path and project_name, sketch+fqbn is ignored.
96-
{"testdata/build_path_2/Blink.ino.hex", "", blonk, fqbn, "testdata/build_path_2", "Blink.ino", false},
95+
{"testdata/build_path_2/Blink.ino.hex", "", blonk, fqbn, "testdata/build_path_2", "Blink.ino"},
9796
// 14: use importPath as build.path and Blink as project name, ignore the sketch Blonk, ignore fqbn
98-
{"", "testdata/build_path_2", blonk, fqbn, "testdata/build_path_2", "Blink.ino", false},
97+
{"", "testdata/build_path_2", blonk, fqbn, "testdata/build_path_2", "Blink.ino"},
9998
// 15: error: used both importPath and importFile
100-
{"testdata/build_path_2/Blink.ino.hex", "testdata/build_path_2", blonk, fqbn, "<nil>", "", true},
99+
{"testdata/build_path_2/Blink.ino.hex", "testdata/build_path_2", blonk, fqbn, "<nil>", ""},
101100
}
102101
for i, test := range tests {
103102
t.Run(fmt.Sprintf("SubTest%02d", i), func(t *testing.T) {
104103
buildPath, sketchName, err := determineBuildPathAndSketchName(test.importFile, test.importDir, test.sketch, test.fqbn)
105-
if test.hasError {
106-
require.Error(t, err)
107-
} else {
108-
require.NoError(t, err)
109-
}
110104
if test.resBuildPath == "<nil>" {
105+
require.Error(t, err)
111106
require.Nil(t, buildPath)
112107
} else {
108+
require.NoError(t, err)
113109
resBuildPath := paths.New(test.resBuildPath)
114110
require.NoError(t, resBuildPath.ToAbs())
111+
require.NotNil(t, buildPath)
115112
require.NoError(t, buildPath.ToAbs())
116113
require.Equal(t, resBuildPath.String(), buildPath.String())
117114
}

0 commit comments

Comments
 (0)