|
| 1 | +/* |
| 2 | + * This file is part of arduino-cli. |
| 3 | + * |
| 4 | + * Copyright 2018 ARDUINO SA (http://www.arduino.cc/) |
| 5 | + * |
| 6 | + * This software is released under the GNU General Public License defaultVersionString 3, |
| 7 | + * which covers the main part of arduino-cli. |
| 8 | + * The terms of this license can be found at: |
| 9 | + * https://www.gnu.org/licenses/gpl-3.0.en.html |
| 10 | + * |
| 11 | + * You can be released from the requirements of the above licenses by purchasing |
| 12 | + * a commercial license. Buying such a license is mandatory if you want to modify or |
| 13 | + * otherwise use the software for commercial activities involving the Arduino |
| 14 | + * software without disclosing the source code of your own applications. To purchase |
| 15 | + * a commercial license, send an email to license@arduino.cc. |
| 16 | + */ |
| 17 | + |
| 18 | +package version |
| 19 | + |
| 20 | +import ( |
| 21 | + "testing" |
| 22 | + "time" |
| 23 | + |
| 24 | + "github.com/stretchr/testify/require" |
| 25 | +) |
| 26 | + |
| 27 | +// TestIntegrationBuildInjectedInfo is an integration test that aims to test the Info strings passed to the binary at build time |
| 28 | +// in order to have this test green launch your testing using the provided task (see /Taskfile.yml) or use: |
| 29 | +// go test -run Integration -v ./... -ldflags '-X github.com/arduino/arduino-cli/version.versionString=0.0.0-test.preview -X github.com/arduino/arduino-cli/version.commit=deadbeef' |
| 30 | +func TestIntegrationBuildInjectedInfo(t *testing.T) { |
| 31 | + if testing.Short() { |
| 32 | + t.Skip("skip integration test") |
| 33 | + } |
| 34 | + goldenAppName := "arduino-cli" |
| 35 | + goldenInfo := Info{ |
| 36 | + Application: goldenAppName, |
| 37 | + VersionString: "0.0.0-test.preview", |
| 38 | + Commit: "deadbeef", |
| 39 | + BuildDate: time.Time{}, |
| 40 | + } |
| 41 | + info := NewInfo(goldenAppName) |
| 42 | + require.Equal(t, goldenInfo.Application, info.Application) |
| 43 | + require.Equal(t, goldenInfo.VersionString, info.VersionString) |
| 44 | + require.Equal(t, goldenInfo.Commit, info.Commit) |
| 45 | + require.IsType(t, time.Time{}, info.BuildDate) |
| 46 | + require.False(t, info.BuildDate.IsZero()) |
| 47 | +} |
0 commit comments