From 03c6700fd28ef07e6e3c23721057859a053be730 Mon Sep 17 00:00:00 2001 From: AYM1607 Date: Fri, 1 Nov 2024 02:14:05 +0000 Subject: [PATCH] Add prerelease test with multiple constraints. Signed-off-by: AYM1607 --- internal/initwd/module_install_test.go | 5 +++++ .../testdata/prerelease-constraint-multiple/root.tf | 13 +++++++++++++ .../initwd/testdata/prerelease-constraint/root.tf | 5 +++++ 3 files changed, 23 insertions(+) create mode 100644 internal/initwd/testdata/prerelease-constraint-multiple/root.tf diff --git a/internal/initwd/module_install_test.go b/internal/initwd/module_install_test.go index 844b2713c8..d62025581e 100644 --- a/internal/initwd/module_install_test.go +++ b/internal/initwd/module_install_test.go @@ -276,6 +276,11 @@ func TestModuleInstaller_Prerelease(t *testing.T) { modulePath: "testdata/prerelease-constraint-v", expectedVersion: "v0.0.2", }, + { + name: "multiple constraints", + modulePath: "testdata/prerelease-constraint-multiple", + shouldError: true, + }, { name: "err", modulePath: "testdata/prerelease-constraint-err", diff --git a/internal/initwd/testdata/prerelease-constraint-multiple/root.tf b/internal/initwd/testdata/prerelease-constraint-multiple/root.tf new file mode 100644 index 0000000000..4cb96d3dda --- /dev/null +++ b/internal/initwd/testdata/prerelease-constraint-multiple/root.tf @@ -0,0 +1,13 @@ +# We expect this test to error out because multiple constraints are +# ANDed, and a prerelease constraint will not match non-prerelease +# versions. +# +# Registry versions are: +# - 0.0.3-alpha.1 +# - 0.0.2 +# - 0.0.1 + +module "acctest" { + source = "hashicorp/module-installer-acctest/aws" + version = "0.0.3-alpha.1, >=0.0.2" +} diff --git a/internal/initwd/testdata/prerelease-constraint/root.tf b/internal/initwd/testdata/prerelease-constraint/root.tf index 0671ee5246..f077eab548 100644 --- a/internal/initwd/testdata/prerelease-constraint/root.tf +++ b/internal/initwd/testdata/prerelease-constraint/root.tf @@ -1,6 +1,11 @@ # We expect this test to download the version 0.0.2, the one before the # specified version even with the equality because the specified version is a # prerelease. +# +# Registry versions are: +# - 0.0.3-alpha.1 +# - 0.0.2 +# - 0.0.1 module "acctest" { source = "hashicorp/module-installer-acctest/aws"