Update tests for the new ProviderResolver interface
Rather than providing an already-resolved map of plugins to core, we now provide a "provider resolver" which knows how to resolve a set of provider dependencies, to be determined later, and produce that map. This requires the context to be instantiated in a different way, so this very noisy diff is a mostly-mechanical update of all of the existing places where contexts get created for testing, using some adapted versions of the pre-existing utilities for passing in mock providers.
This commit is contained in:
parent
7ca592ac06
commit
c835ef8ff3
|
@ -47,14 +47,13 @@ func TestLocalProvider(t *testing.T, b *Local, name string) *terraform.MockResou
|
|||
if b.ContextOpts == nil {
|
||||
b.ContextOpts = &terraform.ContextOpts{}
|
||||
}
|
||||
if b.ContextOpts.Providers == nil {
|
||||
b.ContextOpts.Providers = make(map[string]terraform.ResourceProviderFactory)
|
||||
}
|
||||
|
||||
// Setup our provider
|
||||
b.ContextOpts.Providers[name] = func() (terraform.ResourceProvider, error) {
|
||||
return p, nil
|
||||
}
|
||||
b.ContextOpts.ProviderResolver = terraform.ResourceProviderResolverFixed(
|
||||
map[string]terraform.ResourceProviderFactory{
|
||||
name: terraform.ResourceProviderFactoryFixed(p),
|
||||
},
|
||||
)
|
||||
|
||||
return p
|
||||
}
|
||||
|
|
|
@ -71,21 +71,25 @@ func testFixturePath(name string) string {
|
|||
|
||||
func metaOverridesForProvider(p terraform.ResourceProvider) *testingOverrides {
|
||||
return &testingOverrides{
|
||||
Providers: map[string]terraform.ResourceProviderFactory{
|
||||
"test": func() (terraform.ResourceProvider, error) {
|
||||
return p, nil
|
||||
ProviderResolver: terraform.ResourceProviderResolverFixed(
|
||||
map[string]terraform.ResourceProviderFactory{
|
||||
"test": func() (terraform.ResourceProvider, error) {
|
||||
return p, nil
|
||||
},
|
||||
},
|
||||
},
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
func metaOverridesForProviderAndProvisioner(p terraform.ResourceProvider, pr terraform.ResourceProvisioner) *testingOverrides {
|
||||
return &testingOverrides{
|
||||
Providers: map[string]terraform.ResourceProviderFactory{
|
||||
"test": func() (terraform.ResourceProvider, error) {
|
||||
return p, nil
|
||||
ProviderResolver: terraform.ResourceProviderResolverFixed(
|
||||
map[string]terraform.ResourceProviderFactory{
|
||||
"test": func() (terraform.ResourceProvider, error) {
|
||||
return p, nil
|
||||
},
|
||||
},
|
||||
},
|
||||
),
|
||||
Provisioners: map[string]terraform.ResourceProvisionerFactory{
|
||||
"shell": func() (terraform.ResourceProvisioner, error) {
|
||||
return pr, nil
|
||||
|
|
|
@ -383,11 +383,11 @@ func Test(t TestT, c TestCase) {
|
|||
c.PreCheck()
|
||||
}
|
||||
|
||||
ctxProviders, err := testProviderFactories(c)
|
||||
providerResolver, err := testProviderResolver(c)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
opts := terraform.ContextOpts{Providers: ctxProviders}
|
||||
opts := terraform.ContextOpts{ProviderResolver: providerResolver}
|
||||
|
||||
// A single state variable to track the lifecycle, starting with no state
|
||||
var state *terraform.State
|
||||
|
@ -499,16 +499,17 @@ func Test(t TestT, c TestCase) {
|
|||
}
|
||||
}
|
||||
|
||||
// testProviderFactories is a helper to build the ResourceProviderFactory map
|
||||
// testProviderResolver is a helper to build a ResourceProviderResolver
|
||||
// with pre instantiated ResourceProviders, so that we can reset them for the
|
||||
// test, while only calling the factory function once.
|
||||
// Any errors are stored so that they can be returned by the factory in
|
||||
// terraform to match non-test behavior.
|
||||
func testProviderFactories(c TestCase) (map[string]terraform.ResourceProviderFactory, error) {
|
||||
ctxProviders := c.ProviderFactories // make(map[string]terraform.ResourceProviderFactory)
|
||||
func testProviderResolver(c TestCase) (terraform.ResourceProviderResolver, error) {
|
||||
ctxProviders := c.ProviderFactories
|
||||
if ctxProviders == nil {
|
||||
ctxProviders = make(map[string]terraform.ResourceProviderFactory)
|
||||
}
|
||||
|
||||
// add any fixed providers
|
||||
for k, p := range c.Providers {
|
||||
ctxProviders[k] = terraform.ResourceProviderFactoryFixed(p)
|
||||
|
@ -530,7 +531,7 @@ func testProviderFactories(c TestCase) (map[string]terraform.ResourceProviderFac
|
|||
}
|
||||
}
|
||||
|
||||
return ctxProviders, nil
|
||||
return terraform.ResourceProviderResolverFixed(ctxProviders), nil
|
||||
}
|
||||
|
||||
// UnitTest is a helper to force the acceptance testing harness to run in the
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -9,9 +9,11 @@ import (
|
|||
func TestContextImport_basic(t *testing.T) {
|
||||
p := testProvider("aws")
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
ProviderResolver: ResourceProviderResolverFixed(
|
||||
map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
),
|
||||
})
|
||||
|
||||
p.ImportStateReturn = []*InstanceState{
|
||||
|
@ -42,9 +44,11 @@ func TestContextImport_basic(t *testing.T) {
|
|||
func TestContextImport_countIndex(t *testing.T) {
|
||||
p := testProvider("aws")
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
ProviderResolver: ResourceProviderResolverFixed(
|
||||
map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
),
|
||||
})
|
||||
|
||||
p.ImportStateReturn = []*InstanceState{
|
||||
|
@ -76,9 +80,11 @@ func TestContextImport_countIndex(t *testing.T) {
|
|||
func TestContextImport_collision(t *testing.T) {
|
||||
p := testProvider("aws")
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
ProviderResolver: ResourceProviderResolverFixed(
|
||||
map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
),
|
||||
|
||||
State: &State{
|
||||
Modules: []*ModuleState{
|
||||
|
@ -126,9 +132,11 @@ func TestContextImport_collision(t *testing.T) {
|
|||
func TestContextImport_missingType(t *testing.T) {
|
||||
p := testProvider("aws")
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
ProviderResolver: ResourceProviderResolverFixed(
|
||||
map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
),
|
||||
})
|
||||
|
||||
p.ImportStateReturn = []*InstanceState{
|
||||
|
@ -159,9 +167,11 @@ func TestContextImport_missingType(t *testing.T) {
|
|||
func TestContextImport_moduleProvider(t *testing.T) {
|
||||
p := testProvider("aws")
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
ProviderResolver: ResourceProviderResolverFixed(
|
||||
map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
),
|
||||
})
|
||||
|
||||
p.ImportStateReturn = []*InstanceState{
|
||||
|
@ -212,9 +222,11 @@ func TestContextImport_moduleProvider(t *testing.T) {
|
|||
func TestContextImport_providerInherit(t *testing.T) {
|
||||
p := testProvider("aws")
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
ProviderResolver: ResourceProviderResolverFixed(
|
||||
map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
),
|
||||
})
|
||||
|
||||
p.ImportStateReturn = []*InstanceState{
|
||||
|
@ -261,9 +273,11 @@ func TestContextImport_providerVarConfig(t *testing.T) {
|
|||
p := testProvider("aws")
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Module: testModule(t, "import-provider-vars"),
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
ProviderResolver: ResourceProviderResolverFixed(
|
||||
map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
),
|
||||
Variables: map[string]interface{}{
|
||||
"foo": "bar",
|
||||
},
|
||||
|
@ -315,9 +329,11 @@ func TestContextImport_providerNonVarConfig(t *testing.T) {
|
|||
p := testProvider("aws")
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Module: testModule(t, "import-provider-non-vars"),
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
ProviderResolver: ResourceProviderResolverFixed(
|
||||
map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
),
|
||||
})
|
||||
|
||||
p.ImportStateReturn = []*InstanceState{
|
||||
|
@ -343,9 +359,11 @@ func TestContextImport_providerNonVarConfig(t *testing.T) {
|
|||
func TestContextImport_refresh(t *testing.T) {
|
||||
p := testProvider("aws")
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
ProviderResolver: ResourceProviderResolverFixed(
|
||||
map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
),
|
||||
})
|
||||
|
||||
p.ImportStateReturn = []*InstanceState{
|
||||
|
@ -384,9 +402,11 @@ func TestContextImport_refresh(t *testing.T) {
|
|||
func TestContextImport_refreshNil(t *testing.T) {
|
||||
p := testProvider("aws")
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
ProviderResolver: ResourceProviderResolverFixed(
|
||||
map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
),
|
||||
})
|
||||
|
||||
p.ImportStateReturn = []*InstanceState{
|
||||
|
@ -422,9 +442,11 @@ func TestContextImport_refreshNil(t *testing.T) {
|
|||
func TestContextImport_module(t *testing.T) {
|
||||
p := testProvider("aws")
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
ProviderResolver: ResourceProviderResolverFixed(
|
||||
map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
),
|
||||
})
|
||||
|
||||
p.ImportStateReturn = []*InstanceState{
|
||||
|
@ -456,9 +478,11 @@ func TestContextImport_module(t *testing.T) {
|
|||
func TestContextImport_moduleDepth2(t *testing.T) {
|
||||
p := testProvider("aws")
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
ProviderResolver: ResourceProviderResolverFixed(
|
||||
map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
),
|
||||
})
|
||||
|
||||
p.ImportStateReturn = []*InstanceState{
|
||||
|
@ -490,9 +514,11 @@ func TestContextImport_moduleDepth2(t *testing.T) {
|
|||
func TestContextImport_moduleDiff(t *testing.T) {
|
||||
p := testProvider("aws")
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
ProviderResolver: ResourceProviderResolverFixed(
|
||||
map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
),
|
||||
|
||||
State: &State{
|
||||
Modules: []*ModuleState{
|
||||
|
@ -540,9 +566,11 @@ func TestContextImport_moduleDiff(t *testing.T) {
|
|||
func TestContextImport_moduleExisting(t *testing.T) {
|
||||
p := testProvider("aws")
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
ProviderResolver: ResourceProviderResolverFixed(
|
||||
map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
),
|
||||
|
||||
State: &State{
|
||||
Modules: []*ModuleState{
|
||||
|
@ -590,9 +618,11 @@ func TestContextImport_moduleExisting(t *testing.T) {
|
|||
func TestContextImport_multiState(t *testing.T) {
|
||||
p := testProvider("aws")
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
ProviderResolver: ResourceProviderResolverFixed(
|
||||
map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
),
|
||||
})
|
||||
|
||||
p.ImportStateReturn = []*InstanceState{
|
||||
|
@ -628,9 +658,11 @@ func TestContextImport_multiState(t *testing.T) {
|
|||
func TestContextImport_multiStateSame(t *testing.T) {
|
||||
p := testProvider("aws")
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
ProviderResolver: ResourceProviderResolverFixed(
|
||||
map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
),
|
||||
})
|
||||
|
||||
p.ImportStateReturn = []*InstanceState{
|
||||
|
@ -670,9 +702,11 @@ func TestContextImport_multiStateSame(t *testing.T) {
|
|||
func TestContextImport_customProvider(t *testing.T) {
|
||||
p := testProvider("aws")
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
ProviderResolver: ResourceProviderResolverFixed(
|
||||
map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
),
|
||||
})
|
||||
|
||||
p.ImportStateReturn = []*InstanceState{
|
||||
|
|
|
@ -15,9 +15,11 @@ func TestContext2Input(t *testing.T) {
|
|||
p.DiffFn = testDiffFn
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Module: m,
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
ProviderResolver: ResourceProviderResolverFixed(
|
||||
map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
),
|
||||
Variables: map[string]interface{}{
|
||||
"foo": "us-west-2",
|
||||
"amis": []map[string]interface{}{
|
||||
|
@ -60,9 +62,11 @@ func TestContext2Input_moduleComputedOutputElement(t *testing.T) {
|
|||
p.DiffFn = testDiffFn
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Module: m,
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
ProviderResolver: ResourceProviderResolverFixed(
|
||||
map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
),
|
||||
})
|
||||
|
||||
p.InputFn = func(i UIInput, c *ResourceConfig) (*ResourceConfig, error) {
|
||||
|
@ -81,9 +85,11 @@ func TestContext2Input_badVarDefault(t *testing.T) {
|
|||
p.DiffFn = testDiffFn
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Module: m,
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
ProviderResolver: ResourceProviderResolverFixed(
|
||||
map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
),
|
||||
})
|
||||
|
||||
p.InputFn = func(i UIInput, c *ResourceConfig) (*ResourceConfig, error) {
|
||||
|
@ -103,9 +109,11 @@ func TestContext2Input_provider(t *testing.T) {
|
|||
p.DiffFn = testDiffFn
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Module: m,
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
ProviderResolver: ResourceProviderResolverFixed(
|
||||
map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
),
|
||||
})
|
||||
|
||||
var actual interface{}
|
||||
|
@ -145,9 +153,11 @@ func TestContext2Input_providerMulti(t *testing.T) {
|
|||
p.DiffFn = testDiffFn
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Module: m,
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
ProviderResolver: ResourceProviderResolverFixed(
|
||||
map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
),
|
||||
})
|
||||
|
||||
var actual []interface{}
|
||||
|
@ -191,9 +201,11 @@ func TestContext2Input_providerOnce(t *testing.T) {
|
|||
p.DiffFn = testDiffFn
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Module: m,
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
ProviderResolver: ResourceProviderResolverFixed(
|
||||
map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
),
|
||||
})
|
||||
|
||||
count := 0
|
||||
|
@ -219,9 +231,11 @@ func TestContext2Input_providerId(t *testing.T) {
|
|||
p.DiffFn = testDiffFn
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Module: m,
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
ProviderResolver: ResourceProviderResolverFixed(
|
||||
map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
),
|
||||
UIInput: input,
|
||||
})
|
||||
|
||||
|
@ -269,9 +283,11 @@ func TestContext2Input_providerOnly(t *testing.T) {
|
|||
p.DiffFn = testDiffFn
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Module: m,
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
ProviderResolver: ResourceProviderResolverFixed(
|
||||
map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
),
|
||||
Variables: map[string]interface{}{
|
||||
"foo": "us-west-2",
|
||||
},
|
||||
|
@ -324,9 +340,11 @@ func TestContext2Input_providerVars(t *testing.T) {
|
|||
p.DiffFn = testDiffFn
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Module: m,
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
ProviderResolver: ResourceProviderResolverFixed(
|
||||
map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
),
|
||||
Variables: map[string]interface{}{
|
||||
"foo": "bar",
|
||||
},
|
||||
|
@ -372,9 +390,11 @@ func TestContext2Input_providerVarsModuleInherit(t *testing.T) {
|
|||
p.DiffFn = testDiffFn
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Module: m,
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
ProviderResolver: ResourceProviderResolverFixed(
|
||||
map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
),
|
||||
UIInput: input,
|
||||
})
|
||||
|
||||
|
@ -401,9 +421,11 @@ func TestContext2Input_varOnly(t *testing.T) {
|
|||
p.DiffFn = testDiffFn
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Module: m,
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
ProviderResolver: ResourceProviderResolverFixed(
|
||||
map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
),
|
||||
Variables: map[string]interface{}{
|
||||
"foo": "us-west-2",
|
||||
},
|
||||
|
@ -456,9 +478,11 @@ func TestContext2Input_varOnlyUnset(t *testing.T) {
|
|||
p.DiffFn = testDiffFn
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Module: m,
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
ProviderResolver: ResourceProviderResolverFixed(
|
||||
map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
),
|
||||
Variables: map[string]interface{}{
|
||||
"foo": "foovalue",
|
||||
},
|
||||
|
@ -498,9 +522,11 @@ func TestContext2Input_varWithDefault(t *testing.T) {
|
|||
p.DiffFn = testDiffFn
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Module: m,
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
ProviderResolver: ResourceProviderResolverFixed(
|
||||
map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
),
|
||||
Variables: map[string]interface{}{},
|
||||
UIInput: input,
|
||||
})
|
||||
|
@ -544,9 +570,11 @@ func TestContext2Input_varPartiallyComputed(t *testing.T) {
|
|||
p.DiffFn = testDiffFn
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Module: m,
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
ProviderResolver: ResourceProviderResolverFixed(
|
||||
map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
),
|
||||
Variables: map[string]interface{}{
|
||||
"foo": "foovalue",
|
||||
},
|
||||
|
@ -607,9 +635,11 @@ func TestContext2Input_interpolateVar(t *testing.T) {
|
|||
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Module: m,
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"template": testProviderFuncFixed(p),
|
||||
},
|
||||
ProviderResolver: ResourceProviderResolverFixed(
|
||||
map[string]ResourceProviderFactory{
|
||||
"template": testProviderFuncFixed(p),
|
||||
},
|
||||
),
|
||||
UIInput: input,
|
||||
})
|
||||
|
||||
|
@ -626,9 +656,11 @@ func TestContext2Input_hcl(t *testing.T) {
|
|||
p.DiffFn = testDiffFn
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Module: m,
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"hcl": testProviderFuncFixed(p),
|
||||
},
|
||||
ProviderResolver: ResourceProviderResolverFixed(
|
||||
map[string]ResourceProviderFactory{
|
||||
"hcl": testProviderFuncFixed(p),
|
||||
},
|
||||
),
|
||||
Variables: map[string]interface{}{},
|
||||
UIInput: input,
|
||||
})
|
||||
|
@ -668,9 +700,11 @@ func TestContext2Input_submoduleTriggersInvalidCount(t *testing.T) {
|
|||
p.DiffFn = testDiffFn
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Module: m,
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
ProviderResolver: ResourceProviderResolverFixed(
|
||||
map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
),
|
||||
UIInput: input,
|
||||
})
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -13,9 +13,11 @@ func TestContext2Refresh(t *testing.T) {
|
|||
m := testModule(t, "refresh-basic")
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Module: m,
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
ProviderResolver: ResourceProviderResolverFixed(
|
||||
map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
),
|
||||
State: &State{
|
||||
Modules: []*ModuleState{
|
||||
&ModuleState{
|
||||
|
@ -65,9 +67,11 @@ func TestContext2Refresh_dataComputedModuleVar(t *testing.T) {
|
|||
m := testModule(t, "refresh-data-module-var")
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Module: m,
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
ProviderResolver: ResourceProviderResolverFixed(
|
||||
map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
),
|
||||
})
|
||||
|
||||
p.RefreshFn = nil
|
||||
|
@ -91,9 +95,11 @@ func TestContext2Refresh_targeted(t *testing.T) {
|
|||
m := testModule(t, "refresh-targeted")
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Module: m,
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
ProviderResolver: ResourceProviderResolverFixed(
|
||||
map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
),
|
||||
State: &State{
|
||||
Modules: []*ModuleState{
|
||||
&ModuleState{
|
||||
|
@ -132,9 +138,11 @@ func TestContext2Refresh_targetedCount(t *testing.T) {
|
|||
m := testModule(t, "refresh-targeted-count")
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Module: m,
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
ProviderResolver: ResourceProviderResolverFixed(
|
||||
map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
),
|
||||
State: &State{
|
||||
Modules: []*ModuleState{
|
||||
&ModuleState{
|
||||
|
@ -183,9 +191,11 @@ func TestContext2Refresh_targetedCountIndex(t *testing.T) {
|
|||
m := testModule(t, "refresh-targeted-count")
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Module: m,
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
ProviderResolver: ResourceProviderResolverFixed(
|
||||
map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
),
|
||||
State: &State{
|
||||
Modules: []*ModuleState{
|
||||
&ModuleState{
|
||||
|
@ -226,9 +236,11 @@ func TestContext2Refresh_moduleComputedVar(t *testing.T) {
|
|||
m := testModule(t, "refresh-module-computed-var")
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Module: m,
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
ProviderResolver: ResourceProviderResolverFixed(
|
||||
map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
),
|
||||
})
|
||||
|
||||
// This was failing (see GH-2188) at some point, so this test just
|
||||
|
@ -243,9 +255,11 @@ func TestContext2Refresh_delete(t *testing.T) {
|
|||
m := testModule(t, "refresh-basic")
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Module: m,
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
ProviderResolver: ResourceProviderResolverFixed(
|
||||
map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
),
|
||||
State: &State{
|
||||
Modules: []*ModuleState{
|
||||
&ModuleState{
|
||||
|
@ -282,9 +296,11 @@ func TestContext2Refresh_ignoreUncreated(t *testing.T) {
|
|||
m := testModule(t, "refresh-basic")
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Module: m,
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
ProviderResolver: ResourceProviderResolverFixed(
|
||||
map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
),
|
||||
State: nil,
|
||||
})
|
||||
|
||||
|
@ -309,9 +325,11 @@ func TestContext2Refresh_hook(t *testing.T) {
|
|||
ctx := testContext2(t, &ContextOpts{
|
||||
Module: m,
|
||||
Hooks: []Hook{h},
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
ProviderResolver: ResourceProviderResolverFixed(
|
||||
map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
),
|
||||
State: &State{
|
||||
Modules: []*ModuleState{
|
||||
&ModuleState{
|
||||
|
@ -373,9 +391,11 @@ func TestContext2Refresh_modules(t *testing.T) {
|
|||
}
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Module: m,
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
ProviderResolver: ResourceProviderResolverFixed(
|
||||
map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
),
|
||||
State: state,
|
||||
})
|
||||
|
||||
|
@ -406,9 +426,11 @@ func TestContext2Refresh_moduleInputComputedOutput(t *testing.T) {
|
|||
p.DiffFn = testDiffFn
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Module: m,
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
ProviderResolver: ResourceProviderResolverFixed(
|
||||
map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
),
|
||||
})
|
||||
|
||||
if _, err := ctx.Refresh(); err != nil {
|
||||
|
@ -422,9 +444,11 @@ func TestContext2Refresh_moduleVarModule(t *testing.T) {
|
|||
p.DiffFn = testDiffFn
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Module: m,
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
ProviderResolver: ResourceProviderResolverFixed(
|
||||
map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
),
|
||||
})
|
||||
|
||||
if _, err := ctx.Refresh(); err != nil {
|
||||
|
@ -438,9 +462,11 @@ func TestContext2Refresh_noState(t *testing.T) {
|
|||
m := testModule(t, "refresh-no-state")
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Module: m,
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
ProviderResolver: ResourceProviderResolverFixed(
|
||||
map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
),
|
||||
})
|
||||
|
||||
p.RefreshFn = nil
|
||||
|
@ -458,9 +484,11 @@ func TestContext2Refresh_output(t *testing.T) {
|
|||
m := testModule(t, "refresh-output")
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Module: m,
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
ProviderResolver: ResourceProviderResolverFixed(
|
||||
map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
),
|
||||
State: &State{
|
||||
Modules: []*ModuleState{
|
||||
&ModuleState{
|
||||
|
@ -510,9 +538,11 @@ func TestContext2Refresh_outputPartial(t *testing.T) {
|
|||
m := testModule(t, "refresh-output-partial")
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Module: m,
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
ProviderResolver: ResourceProviderResolverFixed(
|
||||
map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
),
|
||||
State: &State{
|
||||
Modules: []*ModuleState{
|
||||
&ModuleState{
|
||||
|
@ -566,9 +596,11 @@ func TestContext2Refresh_stateBasic(t *testing.T) {
|
|||
}
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Module: m,
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
ProviderResolver: ResourceProviderResolverFixed(
|
||||
map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
),
|
||||
State: state,
|
||||
})
|
||||
|
||||
|
@ -615,9 +647,11 @@ func TestContext2Refresh_dataOrphan(t *testing.T) {
|
|||
},
|
||||
}
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"null": testProviderFuncFixed(p),
|
||||
},
|
||||
ProviderResolver: ResourceProviderResolverFixed(
|
||||
map[string]ResourceProviderFactory{
|
||||
"null": testProviderFuncFixed(p),
|
||||
},
|
||||
),
|
||||
State: state,
|
||||
})
|
||||
|
||||
|
@ -645,9 +679,11 @@ func TestContext2Refresh_dataState(t *testing.T) {
|
|||
}
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Module: m,
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"null": testProviderFuncFixed(p),
|
||||
},
|
||||
ProviderResolver: ResourceProviderResolverFixed(
|
||||
map[string]ResourceProviderFactory{
|
||||
"null": testProviderFuncFixed(p),
|
||||
},
|
||||
),
|
||||
State: state,
|
||||
})
|
||||
|
||||
|
@ -715,9 +751,11 @@ func TestContext2Refresh_dataStateRefData(t *testing.T) {
|
|||
}
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Module: m,
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"null": testProviderFuncFixed(p),
|
||||
},
|
||||
ProviderResolver: ResourceProviderResolverFixed(
|
||||
map[string]ResourceProviderFactory{
|
||||
"null": testProviderFuncFixed(p),
|
||||
},
|
||||
),
|
||||
State: state,
|
||||
})
|
||||
|
||||
|
@ -757,9 +795,11 @@ func TestContext2Refresh_tainted(t *testing.T) {
|
|||
}
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Module: m,
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
ProviderResolver: ResourceProviderResolverFixed(
|
||||
map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
),
|
||||
State: state,
|
||||
})
|
||||
|
||||
|
@ -793,9 +833,13 @@ func TestContext2Refresh_unknownProvider(t *testing.T) {
|
|||
p := testProvider("aws")
|
||||
p.ApplyFn = testApplyFn
|
||||
p.DiffFn = testDiffFn
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Module: m,
|
||||
Providers: map[string]ResourceProviderFactory{},
|
||||
|
||||
_, err := NewContext(&ContextOpts{
|
||||
Module: m,
|
||||
ProviderResolver: ResourceProviderResolverFixed(
|
||||
map[string]ResourceProviderFactory{},
|
||||
),
|
||||
Shadow: true,
|
||||
State: &State{
|
||||
Modules: []*ModuleState{
|
||||
&ModuleState{
|
||||
|
@ -813,8 +857,12 @@ func TestContext2Refresh_unknownProvider(t *testing.T) {
|
|||
},
|
||||
})
|
||||
|
||||
if _, err := ctx.Refresh(); err == nil {
|
||||
t.Fatal("should error")
|
||||
if err == nil {
|
||||
t.Fatal("successfully created context; want error")
|
||||
}
|
||||
|
||||
if !strings.Contains(err.Error(), "Can't satisfy provider requirements") {
|
||||
t.Fatalf("wrong error: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -823,9 +871,11 @@ func TestContext2Refresh_vars(t *testing.T) {
|
|||
m := testModule(t, "refresh-vars")
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Module: m,
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
ProviderResolver: ResourceProviderResolverFixed(
|
||||
map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
),
|
||||
State: &State{
|
||||
|
||||
Modules: []*ModuleState{
|
||||
|
@ -957,9 +1007,11 @@ func TestContext2Refresh_orphanModule(t *testing.T) {
|
|||
}
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Module: m,
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
ProviderResolver: ResourceProviderResolverFixed(
|
||||
map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
),
|
||||
State: state,
|
||||
})
|
||||
|
||||
|
@ -982,9 +1034,11 @@ func TestContext2Validate(t *testing.T) {
|
|||
m := testModule(t, "validate-good")
|
||||
c := testContext2(t, &ContextOpts{
|
||||
Module: m,
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
ProviderResolver: ResourceProviderResolverFixed(
|
||||
map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
),
|
||||
})
|
||||
|
||||
w, e := c.Validate()
|
||||
|
|
|
@ -11,9 +11,11 @@ func TestContext2Validate_badCount(t *testing.T) {
|
|||
m := testModule(t, "validate-bad-count")
|
||||
c := testContext2(t, &ContextOpts{
|
||||
Module: m,
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
ProviderResolver: ResourceProviderResolverFixed(
|
||||
map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
),
|
||||
})
|
||||
|
||||
w, e := c.Validate()
|
||||
|
@ -30,9 +32,11 @@ func TestContext2Validate_badVar(t *testing.T) {
|
|||
m := testModule(t, "validate-bad-var")
|
||||
c := testContext2(t, &ContextOpts{
|
||||
Module: m,
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
ProviderResolver: ResourceProviderResolverFixed(
|
||||
map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
),
|
||||
})
|
||||
|
||||
w, e := c.Validate()
|
||||
|
@ -49,9 +53,11 @@ func TestContext2Validate_varMapOverrideOld(t *testing.T) {
|
|||
p := testProvider("aws")
|
||||
c := testContext2(t, &ContextOpts{
|
||||
Module: m,
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
ProviderResolver: ResourceProviderResolverFixed(
|
||||
map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
),
|
||||
Variables: map[string]interface{}{
|
||||
"foo.foo": "bar",
|
||||
},
|
||||
|
@ -86,10 +92,12 @@ func TestContext2Validate_computedVar(t *testing.T) {
|
|||
m := testModule(t, "validate-computed-var")
|
||||
c := testContext2(t, &ContextOpts{
|
||||
Module: m,
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
"test": testProviderFuncFixed(testProvider("test")),
|
||||
},
|
||||
ProviderResolver: ResourceProviderResolverFixed(
|
||||
map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
"test": testProviderFuncFixed(testProvider("test")),
|
||||
},
|
||||
),
|
||||
})
|
||||
|
||||
p.ValidateFn = func(c *ResourceConfig) ([]string, []error) {
|
||||
|
@ -123,9 +131,11 @@ func TestContext2Validate_countComputed(t *testing.T) {
|
|||
m := testModule(t, "validate-count-computed")
|
||||
c := testContext2(t, &ContextOpts{
|
||||
Module: m,
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
ProviderResolver: ResourceProviderResolverFixed(
|
||||
map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
),
|
||||
})
|
||||
|
||||
w, e := c.Validate()
|
||||
|
@ -142,9 +152,11 @@ func TestContext2Validate_countNegative(t *testing.T) {
|
|||
m := testModule(t, "validate-count-negative")
|
||||
c := testContext2(t, &ContextOpts{
|
||||
Module: m,
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
ProviderResolver: ResourceProviderResolverFixed(
|
||||
map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
),
|
||||
})
|
||||
|
||||
w, e := c.Validate()
|
||||
|
@ -161,9 +173,11 @@ func TestContext2Validate_countVariable(t *testing.T) {
|
|||
m := testModule(t, "apply-count-variable")
|
||||
c := testContext2(t, &ContextOpts{
|
||||
Module: m,
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
ProviderResolver: ResourceProviderResolverFixed(
|
||||
map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
),
|
||||
})
|
||||
|
||||
w, e := c.Validate()
|
||||
|
@ -180,9 +194,11 @@ func TestContext2Validate_countVariableNoDefault(t *testing.T) {
|
|||
m := testModule(t, "validate-count-variable")
|
||||
c := testContext2(t, &ContextOpts{
|
||||
Module: m,
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
ProviderResolver: ResourceProviderResolverFixed(
|
||||
map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
),
|
||||
})
|
||||
|
||||
w, e := c.Validate()
|
||||
|
@ -201,9 +217,11 @@ func TestContext2Validate_cycle(t *testing.T) {
|
|||
m := testModule(t, "validate-cycle")
|
||||
c := testContext2(t, &ContextOpts{
|
||||
Module: m,
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
ProviderResolver: ResourceProviderResolverFixed(
|
||||
map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
),
|
||||
})
|
||||
|
||||
w, e := c.Validate()
|
||||
|
@ -221,9 +239,11 @@ func TestContext2Validate_moduleBadOutput(t *testing.T) {
|
|||
m := testModule(t, "validate-bad-module-output")
|
||||
c := testContext2(t, &ContextOpts{
|
||||
Module: m,
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
ProviderResolver: ResourceProviderResolverFixed(
|
||||
map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
),
|
||||
})
|
||||
|
||||
w, e := c.Validate()
|
||||
|
@ -240,9 +260,11 @@ func TestContext2Validate_moduleGood(t *testing.T) {
|
|||
m := testModule(t, "validate-good-module")
|
||||
c := testContext2(t, &ContextOpts{
|
||||
Module: m,
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
ProviderResolver: ResourceProviderResolverFixed(
|
||||
map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
),
|
||||
})
|
||||
|
||||
w, e := c.Validate()
|
||||
|
@ -259,9 +281,11 @@ func TestContext2Validate_moduleBadResource(t *testing.T) {
|
|||
p := testProvider("aws")
|
||||
c := testContext2(t, &ContextOpts{
|
||||
Module: m,
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
ProviderResolver: ResourceProviderResolverFixed(
|
||||
map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
),
|
||||
})
|
||||
|
||||
p.ValidateResourceReturnErrors = []error{fmt.Errorf("bad")}
|
||||
|
@ -280,9 +304,11 @@ func TestContext2Validate_moduleDepsShouldNotCycle(t *testing.T) {
|
|||
p := testProvider("aws")
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Module: m,
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
ProviderResolver: ResourceProviderResolverFixed(
|
||||
map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
),
|
||||
})
|
||||
|
||||
w, e := ctx.Validate()
|
||||
|
@ -300,9 +326,11 @@ func TestContext2Validate_moduleProviderInherit(t *testing.T) {
|
|||
p := testProvider("aws")
|
||||
c := testContext2(t, &ContextOpts{
|
||||
Module: m,
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
ProviderResolver: ResourceProviderResolverFixed(
|
||||
map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
),
|
||||
})
|
||||
|
||||
p.ValidateFn = func(c *ResourceConfig) ([]string, []error) {
|
||||
|
@ -323,9 +351,11 @@ func TestContext2Validate_moduleProviderInheritOrphan(t *testing.T) {
|
|||
p := testProvider("aws")
|
||||
c := testContext2(t, &ContextOpts{
|
||||
Module: m,
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
ProviderResolver: ResourceProviderResolverFixed(
|
||||
map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
),
|
||||
State: &State{
|
||||
Modules: []*ModuleState{
|
||||
&ModuleState{
|
||||
|
@ -369,9 +399,11 @@ func TestContext2Validate_moduleProviderVar(t *testing.T) {
|
|||
p := testProvider("aws")
|
||||
c := testContext2(t, &ContextOpts{
|
||||
Module: m,
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
ProviderResolver: ResourceProviderResolverFixed(
|
||||
map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
),
|
||||
Variables: map[string]interface{}{
|
||||
"provider_var": "bar",
|
||||
},
|
||||
|
@ -395,9 +427,11 @@ func TestContext2Validate_moduleProviderInheritUnused(t *testing.T) {
|
|||
p := testProvider("aws")
|
||||
c := testContext2(t, &ContextOpts{
|
||||
Module: m,
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
ProviderResolver: ResourceProviderResolverFixed(
|
||||
map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
),
|
||||
})
|
||||
|
||||
p.ValidateFn = func(c *ResourceConfig) ([]string, []error) {
|
||||
|
@ -433,9 +467,11 @@ func TestContext2Validate_orphans(t *testing.T) {
|
|||
}
|
||||
c := testContext2(t, &ContextOpts{
|
||||
Module: m,
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
ProviderResolver: ResourceProviderResolverFixed(
|
||||
map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
),
|
||||
State: state,
|
||||
})
|
||||
|
||||
|
@ -458,9 +494,11 @@ func TestContext2Validate_providerConfig_bad(t *testing.T) {
|
|||
p := testProvider("aws")
|
||||
c := testContext2(t, &ContextOpts{
|
||||
Module: m,
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
ProviderResolver: ResourceProviderResolverFixed(
|
||||
map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
),
|
||||
})
|
||||
|
||||
p.ValidateReturnErrors = []error{fmt.Errorf("bad")}
|
||||
|
@ -482,9 +520,11 @@ func TestContext2Validate_providerConfig_badEmpty(t *testing.T) {
|
|||
p := testProvider("aws")
|
||||
c := testContext2(t, &ContextOpts{
|
||||
Module: m,
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
ProviderResolver: ResourceProviderResolverFixed(
|
||||
map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
),
|
||||
})
|
||||
|
||||
p.ValidateReturnErrors = []error{fmt.Errorf("bad")}
|
||||
|
@ -503,9 +543,11 @@ func TestContext2Validate_providerConfig_good(t *testing.T) {
|
|||
p := testProvider("aws")
|
||||
c := testContext2(t, &ContextOpts{
|
||||
Module: m,
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
ProviderResolver: ResourceProviderResolverFixed(
|
||||
map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
),
|
||||
})
|
||||
|
||||
w, e := c.Validate()
|
||||
|
@ -523,9 +565,11 @@ func TestContext2Validate_provisionerConfig_bad(t *testing.T) {
|
|||
pr := testProvisioner()
|
||||
c := testContext2(t, &ContextOpts{
|
||||
Module: m,
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
ProviderResolver: ResourceProviderResolverFixed(
|
||||
map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
),
|
||||
Provisioners: map[string]ResourceProvisionerFactory{
|
||||
"shell": testProvisionerFuncFixed(pr),
|
||||
},
|
||||
|
@ -554,9 +598,11 @@ func TestContext2Validate_provisionerConfig_good(t *testing.T) {
|
|||
}
|
||||
c := testContext2(t, &ContextOpts{
|
||||
Module: m,
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
ProviderResolver: ResourceProviderResolverFixed(
|
||||
map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
),
|
||||
Provisioners: map[string]ResourceProvisionerFactory{
|
||||
"shell": testProvisionerFuncFixed(pr),
|
||||
},
|
||||
|
@ -576,9 +622,11 @@ func TestContext2Validate_requiredVar(t *testing.T) {
|
|||
p := testProvider("aws")
|
||||
c := testContext2(t, &ContextOpts{
|
||||
Module: m,
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
ProviderResolver: ResourceProviderResolverFixed(
|
||||
map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
),
|
||||
})
|
||||
|
||||
w, e := c.Validate()
|
||||
|
@ -595,9 +643,11 @@ func TestContext2Validate_resourceConfig_bad(t *testing.T) {
|
|||
p := testProvider("aws")
|
||||
c := testContext2(t, &ContextOpts{
|
||||
Module: m,
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
ProviderResolver: ResourceProviderResolverFixed(
|
||||
map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
),
|
||||
})
|
||||
|
||||
p.ValidateResourceReturnErrors = []error{fmt.Errorf("bad")}
|
||||
|
@ -616,9 +666,11 @@ func TestContext2Validate_resourceConfig_good(t *testing.T) {
|
|||
p := testProvider("aws")
|
||||
c := testContext2(t, &ContextOpts{
|
||||
Module: m,
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
ProviderResolver: ResourceProviderResolverFixed(
|
||||
map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
),
|
||||
})
|
||||
|
||||
w, e := c.Validate()
|
||||
|
@ -635,9 +687,11 @@ func TestContext2Validate_resourceNameSymbol(t *testing.T) {
|
|||
m := testModule(t, "validate-resource-name-symbol")
|
||||
c := testContext2(t, &ContextOpts{
|
||||
Module: m,
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
ProviderResolver: ResourceProviderResolverFixed(
|
||||
map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
),
|
||||
})
|
||||
|
||||
w, e := c.Validate()
|
||||
|
@ -654,9 +708,11 @@ func TestContext2Validate_selfRef(t *testing.T) {
|
|||
m := testModule(t, "validate-self-ref")
|
||||
c := testContext2(t, &ContextOpts{
|
||||
Module: m,
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
ProviderResolver: ResourceProviderResolverFixed(
|
||||
map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
),
|
||||
})
|
||||
|
||||
w, e := c.Validate()
|
||||
|
@ -673,9 +729,11 @@ func TestContext2Validate_selfRefMulti(t *testing.T) {
|
|||
m := testModule(t, "validate-self-ref-multi")
|
||||
c := testContext2(t, &ContextOpts{
|
||||
Module: m,
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
ProviderResolver: ResourceProviderResolverFixed(
|
||||
map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
),
|
||||
})
|
||||
|
||||
w, e := c.Validate()
|
||||
|
@ -692,9 +750,11 @@ func TestContext2Validate_selfRefMultiAll(t *testing.T) {
|
|||
m := testModule(t, "validate-self-ref-multi-all")
|
||||
c := testContext2(t, &ContextOpts{
|
||||
Module: m,
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
ProviderResolver: ResourceProviderResolverFixed(
|
||||
map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
),
|
||||
})
|
||||
|
||||
w, e := c.Validate()
|
||||
|
@ -727,9 +787,11 @@ func TestContext2Validate_tainted(t *testing.T) {
|
|||
}
|
||||
c := testContext2(t, &ContextOpts{
|
||||
Module: m,
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
ProviderResolver: ResourceProviderResolverFixed(
|
||||
map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
),
|
||||
State: state,
|
||||
})
|
||||
|
||||
|
@ -755,9 +817,11 @@ func TestContext2Validate_targetedDestroy(t *testing.T) {
|
|||
p.DiffFn = testDiffFn
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Module: m,
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
ProviderResolver: ResourceProviderResolverFixed(
|
||||
map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
),
|
||||
Provisioners: map[string]ResourceProvisionerFactory{
|
||||
"shell": testProvisionerFuncFixed(pr),
|
||||
},
|
||||
|
@ -794,9 +858,11 @@ func TestContext2Validate_varRefFilled(t *testing.T) {
|
|||
p := testProvider("aws")
|
||||
c := testContext2(t, &ContextOpts{
|
||||
Module: m,
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
ProviderResolver: ResourceProviderResolverFixed(
|
||||
map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
),
|
||||
Variables: map[string]interface{}{
|
||||
"foo": "bar",
|
||||
},
|
||||
|
@ -826,9 +892,11 @@ func TestContext2Validate_interpolateVar(t *testing.T) {
|
|||
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Module: m,
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"template": testProviderFuncFixed(p),
|
||||
},
|
||||
ProviderResolver: ResourceProviderResolverFixed(
|
||||
map[string]ResourceProviderFactory{
|
||||
"template": testProviderFuncFixed(p),
|
||||
},
|
||||
),
|
||||
UIInput: input,
|
||||
})
|
||||
|
||||
|
@ -853,9 +921,11 @@ func TestContext2Validate_interpolateComputedModuleVarDef(t *testing.T) {
|
|||
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Module: m,
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
ProviderResolver: ResourceProviderResolverFixed(
|
||||
map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
),
|
||||
UIInput: input,
|
||||
})
|
||||
|
||||
|
@ -879,9 +949,11 @@ func TestContext2Validate_interpolateMap(t *testing.T) {
|
|||
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Module: m,
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"template": testProviderFuncFixed(p),
|
||||
},
|
||||
ProviderResolver: ResourceProviderResolverFixed(
|
||||
map[string]ResourceProviderFactory{
|
||||
"template": testProviderFuncFixed(p),
|
||||
},
|
||||
),
|
||||
UIInput: input,
|
||||
})
|
||||
|
||||
|
@ -902,9 +974,11 @@ func TestContext2Validate_PlanGraphBuilder(t *testing.T) {
|
|||
p.DiffFn = testDiffFn
|
||||
c := testContext2(t, &ContextOpts{
|
||||
Module: m,
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
ProviderResolver: ResourceProviderResolverFixed(
|
||||
map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
),
|
||||
Variables: map[string]interface{}{
|
||||
"foo": "us-west-2",
|
||||
"test_list": []interface{}{"Hello", "World"},
|
||||
|
|
|
@ -98,9 +98,11 @@ func TestDebug_plan(t *testing.T) {
|
|||
p.DiffFn = testDiffFn
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Module: m,
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
ProviderResolver: ResourceProviderResolverFixed(
|
||||
map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
),
|
||||
})
|
||||
|
||||
_, err = ctx.Plan()
|
||||
|
|
Loading…
Reference in New Issue