internal/initwd: Test that version is rejected for local modules

This was already working, but since that codepath is separate from the
go-getter install codepath it's helpful to have a separate test for it,
in addition to the existing one for go-getter modules.
This commit is contained in:
Martin Atkins 2019-05-31 07:57:42 -07:00
parent ab9e98da3c
commit c5285021fa
4 changed files with 50 additions and 9 deletions

View File

@ -129,6 +129,42 @@ func TestModuleInstaller_invalid_version_constraint_error(t *testing.T) {
}
}
func TestModuleInstaller_invalidVersionConstraintGetter(t *testing.T) {
fixtureDir := filepath.Clean("test-fixtures/invalid-version-constraint")
dir, done := tempChdir(t, fixtureDir)
defer done()
hooks := &testInstallHooks{}
modulesDir := filepath.Join(dir, ".terraform/modules")
inst := NewModuleInstaller(modulesDir, nil)
_, diags := inst.InstallModules(".", false, hooks)
if !diags.HasErrors() {
t.Fatal("expected error")
} else {
assertDiagnosticSummary(t, diags, "Invalid version constraint")
}
}
func TestModuleInstaller_invalidVersionConstraintLocal(t *testing.T) {
fixtureDir := filepath.Clean("test-fixtures/invalid-version-constraint-local")
dir, done := tempChdir(t, fixtureDir)
defer done()
hooks := &testInstallHooks{}
modulesDir := filepath.Join(dir, ".terraform/modules")
inst := NewModuleInstaller(modulesDir, nil)
_, diags := inst.InstallModules(".", false, hooks)
if !diags.HasErrors() {
t.Fatal("expected error")
} else {
assertDiagnosticSummary(t, diags, "Invalid version constraint")
}
}
func TestModuleInstaller_symlink(t *testing.T) {
fixtureDir := filepath.Clean("test-fixtures/local-module-symlink")
dir, done := tempChdir(t, fixtureDir)

View File

@ -0,0 +1 @@
.terraform/*

View File

@ -0,0 +1,9 @@
# This fixture references the github repo at:
# https://github.com/hashicorp/terraform-aws-module-installer-acctest
# However, due to the nature of this test (verifying early error), the URL will not be contacted,
# and the test is safe to execute as part of the normal test suite.
module "acctest_root" {
source = "github.com/hashicorp/terraform-aws-module-installer-acctest"
version = "0.0.1"
}

View File

@ -1,9 +1,4 @@
# This fixture references the github repo at:
# https://github.com/hashicorp/terraform-aws-module-installer-acctest
# However, due to the nature of this test (verifying early error), the URL will not be contacted,
# and the test is safe to execute as part of the normal test suite.
module "acctest_root" {
source = "github.com/hashicorp/terraform-aws-module-installer-acctest"
version = "0.0.1"
}
module "local" {
source = "./local"
version = "0.0.1" # Version constraint not allowed for a local module
}