opentofu/version/version_test.go
CJ Horton 49e308e57b unify version information
Instead of having two different places where we keep the current version
which must be manually kept in sync, let's use the same one that the
release process uses (version/VERSION).

Local builds will remain tagged with -dev by default, and we'll
disable this behavior with a linker flag at release time.
2023-07-17 11:11:31 -07:00

28 lines
736 B
Go

package version
import (
"regexp"
"strings"
"testing"
)
// Smoke test to validate that the version file can be read correctly and all exported
// variables include the expected information.
func TestVersion(t *testing.T) {
if match, _ := regexp.MatchString("[^\\d+\\.]", Version); match != false {
t.Fatalf("Version should contain only the main version")
}
if match, _ := regexp.MatchString("[^a-z\\d]", Prerelease); match != false {
t.Fatalf("Prerelease should contain only letters and numbers")
}
if SemVer.Prerelease() != "" {
t.Fatalf("SemVer should not include prerelease information")
}
if !strings.Contains(String(), Prerelease) {
t.Fatalf("Full version string should include prerelease information")
}
}