opentofu/internal/plugin/discovery/version_test.go
Martin Atkins b40a4fb741 Move plugin/ and plugin6/ to internal/plugin{,6}/
This is part of a general effort to move all of Terraform's non-library
package surface under internal in order to reinforce that these are for
internal use within Terraform only.

If you were previously importing packages under this prefix into an
external codebase, you could pin to an earlier release tag as an interim
solution until you've make a plan to achieve the same functionality some
other way.
2021-05-17 14:09:07 -07:00

40 lines
663 B
Go

package discovery
import (
"reflect"
"testing"
)
func TestSortVersions(t *testing.T) {
versions := Versions{
VersionStr("4").MustParse(),
VersionStr("3.1").MustParse(),
VersionStr("1.2").MustParse(),
VersionStr("1.2.3").MustParse(),
VersionStr("2.2.3").MustParse(),
VersionStr("3.2.1").MustParse(),
VersionStr("2.3.2").MustParse(),
}
expected := []string{
"4.0.0",
"3.2.1",
"3.1.0",
"2.3.2",
"2.2.3",
"1.2.3",
"1.2.0",
}
versions.Sort()
var sorted []string
for _, v := range versions {
sorted = append(sorted, v.String())
}
if !reflect.DeepEqual(sorted, expected) {
t.Fatal("versions aren't sorted:", sorted)
}
}