|
| 1 | +// This file is part of arduino-cli. |
| 2 | +// |
| 3 | +// Copyright 2021 ARDUINO SA (http://www.arduino.cc/) |
| 4 | +// |
| 5 | +// This software is released under the GNU General Public License version 3, |
| 6 | +// which covers the main part of arduino-cli. |
| 7 | +// The terms of this license can be found at: |
| 8 | +// https://www.gnu.org/licenses/gpl-3.0.en.html |
| 9 | +// |
| 10 | +// You can be released from the requirements of the above licenses by purchasing |
| 11 | +// a commercial license. Buying such a license is mandatory if you want to |
| 12 | +// modify or otherwise use the software for commercial activities involving the |
| 13 | +// Arduino software without disclosing the source code of your own applications. |
| 14 | +// To purchase a commercial license, send an email to [email protected]. |
| 15 | + |
| 16 | +package commands |
| 17 | + |
| 18 | +import ( |
| 19 | + "fmt" |
| 20 | + "testing" |
| 21 | + |
| 22 | + "github.com/arduino/arduino-cli/arduino/cores" |
| 23 | + "github.com/arduino/arduino-cli/arduino/resources" |
| 24 | + "github.com/arduino/go-paths-helper" |
| 25 | + "github.com/stretchr/testify/require" |
| 26 | + "go.bug.st/downloader/v2" |
| 27 | +) |
| 28 | + |
| 29 | +func TestBundledToolsDownloadAvailability(t *testing.T) { |
| 30 | + tmp, err := paths.MkTempDir("", "") |
| 31 | + require.NoError(t, err) |
| 32 | + defer tmp.RemoveAll() |
| 33 | + |
| 34 | + downloadAndTestChecksum := func(r *resources.DownloadResource) { |
| 35 | + fmt.Println("Testing:", r.URL) |
| 36 | + d, err := r.Download(tmp, &downloader.Config{}) |
| 37 | + require.NoError(t, err) |
| 38 | + err = d.Run() |
| 39 | + require.NoError(t, err) |
| 40 | + |
| 41 | + checksum, err := r.TestLocalArchiveIntegrity(tmp) |
| 42 | + require.True(t, checksum) |
| 43 | + require.NoError(t, err) |
| 44 | + } |
| 45 | + |
| 46 | + toTest := [][]*cores.Flavor{ |
| 47 | + ctagsFlavors, |
| 48 | + serialDiscoveryFlavors, |
| 49 | + mdnsDiscoveryFlavors, |
| 50 | + } |
| 51 | + for _, flavors := range toTest { |
| 52 | + for _, resource := range flavors { |
| 53 | + downloadAndTestChecksum(resource.Resource) |
| 54 | + resource.Resource.ArchivePath(tmp) |
| 55 | + } |
| 56 | + } |
| 57 | +} |
0 commit comments