From 9f1f6c7e78d8a14842928d589acbb4ddedf0e84e Mon Sep 17 00:00:00 2001 From: Patrice Ferlet Date: Tue, 26 Nov 2024 17:53:43 +0100 Subject: [PATCH] test(version): cover the version function --- generator/version_test.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 generator/version_test.go diff --git a/generator/version_test.go b/generator/version_test.go new file mode 100644 index 0000000..44e45c5 --- /dev/null +++ b/generator/version_test.go @@ -0,0 +1,21 @@ +package generator + +import ( + "strings" + "testing" +) + +func TestVersion(t *testing.T) { + // we build on "devel" branch + v := GetVersion() + if strings.Contains(v, "(devel)") { + t.Errorf("Expected version to be set, got %s", v) + } + + // now, imagine we are on a release branch + Version = "release-1.0.0" + v = GetVersion() + if !strings.Contains(v, "release-1.0.0") { + t.Errorf("Expected version to be set, got %s", v) + } +}