|
| 1 | +// This file is part of arduino-cli. |
| 2 | +// |
| 3 | +// Copyright 2020 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 cores |
| 17 | + |
| 18 | +import ( |
| 19 | + "testing" |
| 20 | + |
| 21 | + "github.com/stretchr/testify/require" |
| 22 | + semver "go.bug.st/relaxed-semver" |
| 23 | +) |
| 24 | + |
| 25 | +func TestRequiresToolRelease(t *testing.T) { |
| 26 | + toolDependencyName := "avr-gcc" |
| 27 | + toolDependencyVersion := "7.3.0-atmel3.6.1-arduino7" |
| 28 | + toolDependencyPackager := "arduino" |
| 29 | + |
| 30 | + release := PlatformRelease{ |
| 31 | + Dependencies: ToolDependencies{ |
| 32 | + { |
| 33 | + ToolName: toolDependencyName, |
| 34 | + ToolVersion: semver.ParseRelaxed(toolDependencyVersion), |
| 35 | + ToolPackager: toolDependencyPackager, |
| 36 | + }, |
| 37 | + }, |
| 38 | + } |
| 39 | + |
| 40 | + toolRelease := &ToolRelease{ |
| 41 | + Version: semver.ParseRelaxed(toolDependencyVersion + "not"), |
| 42 | + Tool: &Tool{ |
| 43 | + Name: toolDependencyName + "not", |
| 44 | + Package: &Package{ |
| 45 | + Name: toolDependencyPackager + "not", |
| 46 | + }, |
| 47 | + }, |
| 48 | + } |
| 49 | + |
| 50 | + require.False(t, release.RequiresToolRelease(toolRelease)) |
| 51 | + toolRelease.Tool.Name = toolDependencyName |
| 52 | + require.False(t, release.RequiresToolRelease(toolRelease)) |
| 53 | + toolRelease.Tool.Package.Name = toolDependencyPackager |
| 54 | + require.False(t, release.RequiresToolRelease(toolRelease)) |
| 55 | + toolRelease.Version = semver.ParseRelaxed(toolDependencyVersion) |
| 56 | + require.True(t, release.RequiresToolRelease(toolRelease)) |
| 57 | +} |
0 commit comments