Skip to content

Commit 1234df7

Browse files
committed
Use shared download folder for testing (saves bandwidth)
1 parent 61323e0 commit 1234df7

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

commands/commands_test.go

+12-5
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@ func TestUploadCommands(t *testing.T) {
257257
func TestLibSearch(t *testing.T) {
258258
defer makeTempDataDir(t)()
259259
defer makeTempSketchbookDir(t)()
260+
defer useSharedDownloadDir(t)()
260261

261262
exitCode, output := executeWithArgs(t, "lib", "search", "audiozer", "--format", "json")
262263
require.Zero(t, exitCode, "process exit code")
@@ -287,6 +288,7 @@ func TestLibSearch(t *testing.T) {
287288
func TestUserLibs(t *testing.T) {
288289
defer makeTempDataDir(t)()
289290
defer makeTempSketchbookDir(t)()
291+
defer useSharedDownloadDir(t)()
290292
libDir := currSketchbookDir.Join("libraries")
291293
err := libDir.MkdirAll()
292294
require.NoError(t, err, "creating 'sketchbook/libraries' dir")
@@ -323,6 +325,7 @@ func TestSketchCommands(t *testing.T) {
323325
defer makeTempSketchbookDir(t)()
324326
//var d []byte
325327
var exitCode int
328+
defer useSharedDownloadDir(t)()
326329

327330
exitCode, _ = executeWithArgs(t, "sketch", "new", "Test")
328331
require.Zero(t, exitCode, "exit code")
@@ -333,6 +336,7 @@ func TestLibDownloadAndInstall(t *testing.T) {
333336
defer makeTempSketchbookDir(t)()
334337
var d []byte
335338
var exitCode int
339+
defer useSharedDownloadDir(t)()
336340

337341
exitCode, _ = executeWithArgs(t, "core", "update-index")
338342
require.Zero(t, exitCode, "exit code")
@@ -475,6 +479,7 @@ func detectLatestAVRCore(t *testing.T) string {
475479
func TestCompileCommands(t *testing.T) {
476480
defer makeTempDataDir(t)()
477481
defer makeTempSketchbookDir(t)()
482+
defer useSharedDownloadDir(t)()
478483

479484
// Set staging dir to a temporary dir
480485
tmp, err := ioutil.TempDir(os.TempDir(), "test")
@@ -532,6 +537,7 @@ func TestCompileCommands(t *testing.T) {
532537
func TestInvalidCoreURL(t *testing.T) {
533538
defer makeTempDataDir(t)()
534539
defer makeTempSketchbookDir(t)()
540+
defer useSharedDownloadDir(t)()
535541

536542
tmp, err := paths.MkTempDir("", "")
537543
require.NoError(t, err, "making temporary dir")
@@ -568,6 +574,7 @@ board_manager:
568574
func TestCoreCommands(t *testing.T) {
569575
defer makeTempDataDir(t)()
570576
defer makeTempSketchbookDir(t)()
577+
defer useSharedDownloadDir(t)()
571578

572579
// Set staging dir to a temporary dir
573580
tmp, err := ioutil.TempDir(os.TempDir(), "test")
@@ -580,15 +587,15 @@ func TestCoreCommands(t *testing.T) {
580587
// Download a specific core version
581588
exitCode, d := executeWithArgs(t, "core", "download", "arduino:[email protected]")
582589
require.Zero(t, exitCode, "exit code")
583-
require.Contains(t, string(d), "arduino:[email protected] downloaded")
584-
require.Contains(t, string(d), "arduino:[email protected] downloaded")
585-
require.Contains(t, string(d), "arduino:[email protected] downloaded")
586-
require.Contains(t, string(d), "arduino:[email protected] downloaded")
590+
require.Regexp(t, "arduino:[email protected] (already )?downloaded", string(d))
591+
require.Regexp(t, "arduino:[email protected] (already )?downloaded", string(d))
592+
require.Regexp(t, "arduino:[email protected] (already )?downloaded", string(d))
593+
require.Regexp(t, "arduino:[email protected] (already )?downloaded", string(d))
587594

588595
// Download latest
589596
exitCode, d = executeWithArgs(t, "core", "download", "arduino:avr")
590597
require.Zero(t, exitCode, "exit code")
591-
require.Contains(t, string(d), AVR+" downloaded")
598+
require.Regexp(t, AVR+" (already )?downloaded", string(d))
592599

593600
// Wrong downloads
594601
exitCode, d = executeWithArgs(t, "core", "download", "arduino:[email protected]")

0 commit comments

Comments
 (0)