mirror of
https://github.com/opentofu/opentofu.git
synced 2025-01-11 00:22:32 -06:00
adds tests for module prerelease version constraints with a v prefix
Signed-off-by: AYM1607 <u.g.a.mariano@gmail.com>
This commit is contained in:
parent
5264ccee99
commit
6a5c1a2f42
@ -235,57 +235,61 @@ func TestModuleInstaller_explicitPackageBoundary(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestModuleInstaller_ExactMatchPrerelease(t *testing.T) {
|
func TestModuleInstaller_Prerelease(t *testing.T) {
|
||||||
if os.Getenv("TF_ACC") == "" {
|
if os.Getenv("TF_ACC") == "" {
|
||||||
t.Skip("this test accesses registry.opentofu.org and github.com; set TF_ACC=1 to run it")
|
t.Skip("this test accesses registry.opentofu.org and github.com; set TF_ACC=1 to run it")
|
||||||
}
|
}
|
||||||
|
|
||||||
fixtureDir := filepath.Clean("testdata/prerelease-version-constraint-match")
|
testCases := []struct {
|
||||||
dir, done := tempChdir(t, fixtureDir)
|
name string
|
||||||
defer done()
|
modulePath string
|
||||||
|
expectedVersion string
|
||||||
hooks := &testInstallHooks{}
|
}{
|
||||||
|
{
|
||||||
modulesDir := filepath.Join(dir, ".terraform/modules")
|
name: "exact match",
|
||||||
|
modulePath: "testdata/prerelease-version-constraint-match",
|
||||||
loader, close := configload.NewLoaderForTests(t)
|
expectedVersion: "v0.0.3-alpha.1",
|
||||||
defer close()
|
},
|
||||||
inst := NewModuleInstaller(modulesDir, loader, registry.NewClient(nil, nil))
|
{
|
||||||
cfg, diags := inst.InstallModules(context.Background(), ".", "tests", false, false, hooks, configs.RootModuleCallForTesting())
|
name: "exact match v prefix",
|
||||||
|
modulePath: "testdata/prerelease-version-constraint-match-prefix",
|
||||||
if diags.HasErrors() {
|
expectedVersion: "v0.0.3-alpha.1",
|
||||||
t.Fatalf("found unexpected errors: %s", diags.Err())
|
},
|
||||||
|
{
|
||||||
|
name: "exact match v prefix eq selector",
|
||||||
|
modulePath: "testdata/prerelease-version-constraint-match-prefix-eq",
|
||||||
|
expectedVersion: "v0.0.3-alpha.1",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "partial match",
|
||||||
|
modulePath: "testdata/prerelease-version-constraint",
|
||||||
|
expectedVersion: "v0.0.2",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
if !cfg.Children["acctest_exact"].Version.Equal(version.Must(version.NewVersion("v0.0.3-alpha.1"))) {
|
for _, tc := range testCases {
|
||||||
t.Fatalf("expected version %s but found version %s", "v0.0.3-alpha.1", cfg.Version.String())
|
t.Run(tc.name, func(t *testing.T) {
|
||||||
}
|
fixtureDir := filepath.Clean(tc.modulePath)
|
||||||
}
|
dir, done := tempChdir(t, fixtureDir)
|
||||||
|
defer done()
|
||||||
|
|
||||||
func TestModuleInstaller_PartialMatchPrerelease(t *testing.T) {
|
hooks := &testInstallHooks{}
|
||||||
if os.Getenv("TF_ACC") == "" {
|
|
||||||
t.Skip("this test accesses registry.opentofu.org and github.com; set TF_ACC=1 to run it")
|
|
||||||
}
|
|
||||||
|
|
||||||
fixtureDir := filepath.Clean("testdata/prerelease-version-constraint")
|
modulesDir := filepath.Join(dir, ".terraform/modules")
|
||||||
dir, done := tempChdir(t, fixtureDir)
|
|
||||||
defer done()
|
|
||||||
|
|
||||||
hooks := &testInstallHooks{}
|
loader, close := configload.NewLoaderForTests(t)
|
||||||
|
defer close()
|
||||||
|
inst := NewModuleInstaller(modulesDir, loader, registry.NewClient(nil, nil))
|
||||||
|
cfg, diags := inst.InstallModules(context.Background(), ".", "tests", false, false, hooks, configs.RootModuleCallForTesting())
|
||||||
|
|
||||||
modulesDir := filepath.Join(dir, ".terraform/modules")
|
if diags.HasErrors() {
|
||||||
|
t.Fatalf("found unexpected errors: %s", diags.Err())
|
||||||
|
}
|
||||||
|
|
||||||
loader, close := configload.NewLoaderForTests(t)
|
if !cfg.Children["acctest"].Version.Equal(version.Must(version.NewVersion(tc.expectedVersion))) {
|
||||||
defer close()
|
t.Fatalf("expected version %s but found version %s", tc.expectedVersion, cfg.Version.String())
|
||||||
inst := NewModuleInstaller(modulesDir, loader, registry.NewClient(nil, nil))
|
}
|
||||||
cfg, diags := inst.InstallModules(context.Background(), ".", "tests", false, false, hooks, configs.RootModuleCallForTesting())
|
})
|
||||||
|
|
||||||
if diags.HasErrors() {
|
|
||||||
t.Fatalf("found unexpected errors: %s", diags.Err())
|
|
||||||
}
|
|
||||||
|
|
||||||
if !cfg.Children["acctest_partial"].Version.Equal(version.Must(version.NewVersion("v0.0.2"))) {
|
|
||||||
t.Fatalf("expected version %s but found version %s", "v0.0.2", cfg.Version.String())
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
7
internal/initwd/testdata/prerelease-version-constraint-match-prefix-eq/root.tf
vendored
Normal file
7
internal/initwd/testdata/prerelease-version-constraint-match-prefix-eq/root.tf
vendored
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
# We expect this test to download the requested version because it is an exact
|
||||||
|
# match for a prerelease version.
|
||||||
|
|
||||||
|
module "acctest" {
|
||||||
|
source = "hashicorp/module-installer-acctest/aws"
|
||||||
|
version = "=v0.0.3-alpha.1"
|
||||||
|
}
|
7
internal/initwd/testdata/prerelease-version-constraint-match-prefix/root.tf
vendored
Normal file
7
internal/initwd/testdata/prerelease-version-constraint-match-prefix/root.tf
vendored
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
# We expect this test to download the requested version because it is an exact
|
||||||
|
# match for a prerelease version.
|
||||||
|
|
||||||
|
module "acctest" {
|
||||||
|
source = "hashicorp/module-installer-acctest/aws"
|
||||||
|
version = "v0.0.3-alpha.1"
|
||||||
|
}
|
@ -1,7 +1,7 @@
|
|||||||
# We expect this test to download the requested version because it is an exact
|
# We expect this test to download the requested version because it is an exact
|
||||||
# match for a prerelease version.
|
# match for a prerelease version.
|
||||||
|
|
||||||
module "acctest_exact" {
|
module "acctest" {
|
||||||
source = "hashicorp/module-installer-acctest/aws"
|
source = "hashicorp/module-installer-acctest/aws"
|
||||||
version = "=0.0.3-alpha.1"
|
version = "=0.0.3-alpha.1"
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
# specified version even with the equality because the specified version is a
|
# specified version even with the equality because the specified version is a
|
||||||
# prerelease.
|
# prerelease.
|
||||||
|
|
||||||
module "acctest_partial" {
|
module "acctest" {
|
||||||
source = "hashicorp/module-installer-acctest/aws"
|
source = "hashicorp/module-installer-acctest/aws"
|
||||||
version = "<=0.0.3-alpha.1"
|
version = "<=0.0.3-alpha.1"
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user