From 81eb136ac912372b66d834dde8d3090027546244 Mon Sep 17 00:00:00 2001 From: Umberto Baldi Date: Fri, 15 Dec 2023 11:41:25 +0100 Subject: [PATCH] enlarge the scope of the test: verify dir tree is handled correctly --- tools/download_test.go | 34 ++++++++++++------ tools/testdata/test_tool_index.json | 55 +++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+), 11 deletions(-) diff --git a/tools/download_test.go b/tools/download_test.go index faf38d13d..1a66f4fdb 100644 --- a/tools/download_test.go +++ b/tools/download_test.go @@ -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() @@ -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) diff --git a/tools/testdata/test_tool_index.json b/tools/testdata/test_tool_index.json index b7f8b87d2..fdee1cc9d 100644 --- a/tools/testdata/test_tool_index.json +++ b/tools/testdata/test_tool_index.json @@ -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" + } + ] } ] }