Skip to content

Commit

Permalink
enlarge the scope of the test: verify dir tree is handled correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
umbynos committed Dec 15, 2023
1 parent 872d230 commit 81eb136
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 11 deletions.
34 changes: 23 additions & 11 deletions tools/download_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,18 +96,20 @@ func TestDownloadFallbackPlatform(t *testing.T) {

func TestDownload(t *testing.T) {
testCases := []struct {
name string
version string
name string
version string
filesCreated []string
}{
{"avrdude", "6.3.0-arduino17"},
{"bossac", "1.6.1-arduino"},
{"bossac", "1.7.0-arduino3"},
{"bossac", "1.9.1-arduino2"},
{"openocd", "0.11.0-arduino2"},
{"dfu-util", "0.10.0-arduino1"},
{"rp2040tools", "1.0.6"},
{"esptool_py", "4.5.1"},
{"arduino-fwuploader", "2.2.2"},
{"avrdude", "6.3.0-arduino17", []string{"bin", "etc"}},
{"bossac", "1.6.1-arduino", []string{"bossac"}},
{"bossac", "1.7.0-arduino3", []string{"bossac"}},
{"bossac", "1.9.1-arduino2", []string{"bossac"}},
{"openocd", "0.11.0-arduino2", []string{"bin", "share"}},
{"dfu-util", "0.10.0-arduino1", []string{"dfu-prefix", "dfu-suffix", "dfu-util"}},
{"rp2040tools", "1.0.6", []string{"elf2uf2", "picotool", "pioasm", "rp2040load"}},
{"esptool_py", "4.5.1", []string{"esptool", "esptool.py"}},
{"arduino-fwuploader", "2.2.2", []string{"arduino-fwuploader", "LICENSE.txt"}},
{"fwupdater", "0.1.12", []string{"firmwares", "FirmwareUploader", "LICENSE.txt"}}, // old legacy tool
}
// prepare the test environment
tempDir := t.TempDir()
Expand All @@ -128,6 +130,16 @@ func TestDownload(t *testing.T) {
toolDir := tempDirPath.Join("arduino-test", tc.name, tc.version)
require.DirExists(t, toolDir.String())

// Check that the files have been created
for _, file := range tc.filesCreated {
filePath := toolDir.Join(file)
if filePath.IsDir() {
require.DirExists(t, filePath.String())
} else {
require.FileExists(t, filePath.String())
}
}

// Check that the tool has been installed
_, ok := testTools.getMapValue(tc.name + "-" + tc.version)
require.True(t, ok)
Expand Down
55 changes: 55 additions & 0 deletions tools/testdata/test_tool_index.json
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,61 @@
"size": "6829396"
}
]
},
{
"name": "fwupdater",
"version": "0.1.12",
"systems": [
{
"host": "i686-linux-gnu",
"url": "http://downloads.arduino.cc/tools/FirmwareUploader_0.1.12_Linux_32bit.tar.bz2",
"archiveFileName": "FirmwareUploader_0.1.12_Linux_32bit.tar.bz2",
"checksum": "SHA-256:2fec2bdfd20ad4950bc9ba37108dc2a7c152f569174279c0697efe1f5a0db781",
"size": "26097546"
},
{
"host": "x86_64-pc-linux-gnu",
"url": "http://downloads.arduino.cc/tools/FirmwareUploader_0.1.12_Linux_64bit.tar.bz2",
"archiveFileName": "FirmwareUploader_0.1.12_Linux_64bit.tar.bz2",
"checksum": "SHA-256:ce57d0afef30cb7d3513f5da326346c99d6bf4923bbc2200634086811f3fb31e",
"size": "26073327"
},
{
"host": "i686-mingw32",
"url": "http://downloads.arduino.cc/tools/FirmwareUploader_0.1.12_Windows_32bit.zip",
"archiveFileName": "FirmwareUploader_0.1.12_Windows_32bit.zip",
"checksum": "SHA-256:558568b453caa1c821def8cc6d34555d0c910eb7e7e871de3ae1c39ae6f01bdd",
"size": "25743641"
},
{
"host": "x86_64-mingw32",
"url": "http://downloads.arduino.cc/tools/FirmwareUploader_0.1.12_Windows_64bit.zip",
"archiveFileName": "FirmwareUploader_0.1.12_Windows_64bit.zip",
"checksum": "SHA-256:ec16de33620985434280c92c3c322257b89bb67adf8fd4d5dd5f9467ea1e9e40",
"size": "25851428"
},
{
"host": "i386-apple-darwin11",
"url": "http://downloads.arduino.cc/tools/FirmwareUploader_0.1.12_macOS_64bit.tar.bz2",
"archiveFileName": "FirmwareUploader_0.1.12_macOS_64bit.tar.bz2",
"checksum": "SHA-256:a470361b57f86ddfcaecd274d844af51ee1d23a71cd6c26e30fcef2152d1a03f",
"size": "25792860"
},
{
"host": "arm-linux-gnueabihf",
"url": "http://downloads.arduino.cc/tools/FirmwareUploader_0.1.12_Linux_ARM.tar.bz2",
"archiveFileName": "FirmwareUploader_0.1.12_Linux_ARM.tar.bz2",
"checksum": "SHA-256:855fa0a9b942c3ee18906efc510bdfe30bf3334ff28ffbb476e648ff30033847",
"size": "25936245"
},
{
"host": "aarch64-linux-gnu",
"url": "http://downloads.arduino.cc/tools/FirmwareUploader_0.1.12_Linux_ARM64.tar.bz2",
"archiveFileName": "FirmwareUploader_0.1.12_Linux_ARM64.tar.bz2",
"checksum": "SHA-256:691461e64fe075e9a79801347c2bd895fb72f8f2c45a7cd49056c6ad9efe8fc4",
"size": "25967430"
}
]
}
]
}
Expand Down

0 comments on commit 81eb136

Please sign in to comment.