From 38246cd54fda30fee13c74aacb5d89cca68236b7 Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Mon, 17 Oct 2022 21:41:35 +0300 Subject: [PATCH] [#284] tests: Add a test for checking VERSION file Signed-off-by: Evgenii Stratonikov --- tests/version_test.go | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 tests/version_test.go diff --git a/tests/version_test.go b/tests/version_test.go new file mode 100644 index 0000000..e46c015 --- /dev/null +++ b/tests/version_test.go @@ -0,0 +1,29 @@ +package tests + +import ( + "os" + "strconv" + "strings" + "testing" + + "github.com/nspcc-dev/neofs-contract/common" + "github.com/stretchr/testify/require" +) + +func TestVersion(t *testing.T) { + data, err := os.ReadFile("../VERSION") + require.NoError(t, err) + + v := strings.TrimPrefix(string(data), "v") + parts := strings.Split(strings.TrimSpace(v), ".") + require.Len(t, parts, 3) + + var ver [3]int + for i := range parts { + ver[i], err = strconv.Atoi(parts[i]) + require.NoError(t, err) + } + + require.Equal(t, common.Version, ver[0]*1_000_000+ver[1]*1_000+ver[2], + "version from common package is different from the one in VERSION file") +}