2024-02-08 03:48:59 -06:00
|
|
|
// Copyright (c) The OpenTofu Authors
|
|
|
|
// SPDX-License-Identifier: MPL-2.0
|
|
|
|
// Copyright (c) 2023 HashiCorp, Inc.
|
2023-04-10 17:57:24 -05:00
|
|
|
// SPDX-License-Identifier: MPL-2.0
|
|
|
|
|
2023-04-03 22:38:30 -05:00
|
|
|
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")
|
|
|
|
}
|
|
|
|
}
|