mirror of
https://github.com/opentffoundation/opentf.git
synced 2025-12-19 17:59:05 -05:00
initwd: Fix the TF_ACC=1 tests
Earlier work in opentofu/opentofu#2661 caused the module installer to treat the registry client and the package fetcher as optional dependencies so that local-only tests (by far our common case across the whole codebase) could avoid instantiating the registry and go-getter client code and risk accidentally depending on network services. However, at the time I didn't notice that this package had TF_ACC=1 acceptance tests, and so although I made systematic updates across all the tests which appeared to make them pass there were actually several that were being skipped and so I didn't notice that I hadn't updated them well enough. This gets them all passing again by giving the ones that intentionally access the real OpenTofu Registry and some test-only GitHub repositories the clients they need to do that. In a future commit I intend to add this package to our end-to-end test job that runs as part of our pull request checks so that we're less likely to forget to update these tests under future maintenance. Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
This commit is contained in:
@@ -45,8 +45,9 @@ func TestDirFromModule_registry(t *testing.T) {
|
||||
hooks := &testInstallHooks{}
|
||||
|
||||
reg := registry.NewClient(t.Context(), nil, nil)
|
||||
fetcher := getmodules.NewPackageFetcher(t.Context(), nil)
|
||||
loader := configload.NewLoaderForTests(t)
|
||||
diags := DirFromModule(context.Background(), loader, dir, modsDir, "hashicorp/module-installer-acctest/aws//examples/main", reg, nil, hooks)
|
||||
diags := DirFromModule(t.Context(), loader, dir, modsDir, "hashicorp/module-installer-acctest/aws//examples/main", reg, fetcher, hooks)
|
||||
assertNoDiagnostics(t, diags)
|
||||
|
||||
v := version.Must(version.NewVersion("0.0.2"))
|
||||
|
||||
@@ -305,7 +305,9 @@ func TestModuleInstaller_Prerelease(t *testing.T) {
|
||||
modulesDir := filepath.Join(dir, ".terraform/modules")
|
||||
|
||||
loader := configload.NewLoaderForTests(t)
|
||||
inst := NewModuleInstaller(modulesDir, loader, registry.NewClient(t.Context(), nil, nil), nil)
|
||||
reg := registry.NewClient(t.Context(), nil, nil)
|
||||
fetcher := getmodules.NewPackageFetcher(t.Context(), nil)
|
||||
inst := NewModuleInstaller(modulesDir, loader, reg, fetcher)
|
||||
cfg, diags := inst.InstallModules(context.Background(), ".", "tests", false, false, hooks, configs.RootModuleCallForTesting())
|
||||
|
||||
if tc.shouldError {
|
||||
@@ -480,7 +482,9 @@ func TestLoaderInstallModules_registry(t *testing.T) {
|
||||
modulesDir := filepath.Join(dir, ".terraform/modules")
|
||||
|
||||
loader := configload.NewLoaderForTests(t)
|
||||
inst := NewModuleInstaller(modulesDir, loader, registry.NewClient(t.Context(), nil, nil), nil)
|
||||
reg := registry.NewClient(t.Context(), nil, nil)
|
||||
fetcher := getmodules.NewPackageFetcher(t.Context(), nil)
|
||||
inst := NewModuleInstaller(modulesDir, loader, reg, fetcher)
|
||||
_, diags := inst.InstallModules(context.Background(), dir, "tests", false, false, hooks, configs.RootModuleCallForTesting())
|
||||
assertNoDiagnostics(t, diags)
|
||||
|
||||
@@ -640,7 +644,9 @@ func TestLoaderInstallModules_goGetter(t *testing.T) {
|
||||
modulesDir := filepath.Join(dir, ".terraform/modules")
|
||||
|
||||
loader := configload.NewLoaderForTests(t)
|
||||
inst := NewModuleInstaller(modulesDir, loader, registry.NewClient(t.Context(), nil, nil), nil)
|
||||
reg := registry.NewClient(t.Context(), nil, nil)
|
||||
fetcher := getmodules.NewPackageFetcher(t.Context(), nil)
|
||||
inst := NewModuleInstaller(modulesDir, loader, reg, fetcher)
|
||||
_, diags := inst.InstallModules(context.Background(), dir, "tests", false, false, hooks, configs.RootModuleCallForTesting())
|
||||
assertNoDiagnostics(t, diags)
|
||||
|
||||
@@ -809,7 +815,9 @@ func TestLoadInstallModules_registryFromTest(t *testing.T) {
|
||||
modulesDir := filepath.Join(dir, ".terraform/modules")
|
||||
|
||||
loader := configload.NewLoaderForTests(t)
|
||||
inst := NewModuleInstaller(modulesDir, loader, registry.NewClient(t.Context(), nil, nil), nil)
|
||||
reg := registry.NewClient(t.Context(), nil, nil)
|
||||
fetcher := getmodules.NewPackageFetcher(t.Context(), nil)
|
||||
inst := NewModuleInstaller(modulesDir, loader, reg, fetcher)
|
||||
_, diags := inst.InstallModules(context.Background(), dir, "tests", false, false, hooks, configs.RootModuleCallForTesting())
|
||||
assertNoDiagnostics(t, diags)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user