mirror of
https://github.com/opentofu/opentofu.git
synced 2024-12-28 18:01:01 -06:00
terraform: convert more tests
This commit is contained in:
parent
23bb182732
commit
220c2be571
@ -268,6 +268,35 @@ func TestContext2Validate_provisionerConfig_bad(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestContext2Validate_provisionerConfig_good(t *testing.T) {
|
||||
m := testModule(t, "validate-bad-prov-conf")
|
||||
p := testProvider("aws")
|
||||
pr := testProvisioner()
|
||||
pr.ValidateFn = func(c *ResourceConfig) ([]string, []error) {
|
||||
if c == nil {
|
||||
t.Fatalf("missing resource config for provisioner")
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
c := testContext2(t, &ContextOpts{
|
||||
Module: m,
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
Provisioners: map[string]ResourceProvisionerFactory{
|
||||
"shell": testProvisionerFuncFixed(pr),
|
||||
},
|
||||
})
|
||||
|
||||
w, e := c.Validate()
|
||||
if len(w) > 0 {
|
||||
t.Fatalf("bad: %#v", w)
|
||||
}
|
||||
if len(e) > 0 {
|
||||
t.Fatalf("bad: %#v", e)
|
||||
}
|
||||
}
|
||||
|
||||
func TestContext2Validate_requiredVar(t *testing.T) {
|
||||
m := testModule(t, "validate-required-var")
|
||||
p := testProvider("aws")
|
||||
@ -537,35 +566,6 @@ func TestContextValidate_tainted(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestContextValidate_provisionerConfig_good(t *testing.T) {
|
||||
m := testModule(t, "validate-bad-prov-conf")
|
||||
p := testProvider("aws")
|
||||
pr := testProvisioner()
|
||||
pr.ValidateFn = func(c *ResourceConfig) ([]string, []error) {
|
||||
if c == nil {
|
||||
t.Fatalf("missing resource config for provisioner")
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
c := testContext(t, &ContextOpts{
|
||||
Module: m,
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
},
|
||||
Provisioners: map[string]ResourceProvisionerFactory{
|
||||
"shell": testProvisionerFuncFixed(pr),
|
||||
},
|
||||
})
|
||||
|
||||
w, e := c.Validate()
|
||||
if len(w) > 0 {
|
||||
t.Fatalf("bad: %#v", w)
|
||||
}
|
||||
if len(e) > 0 {
|
||||
t.Fatalf("bad: %#v", e)
|
||||
}
|
||||
}
|
||||
|
||||
func TestContextInput(t *testing.T) {
|
||||
input := new(MockUIInput)
|
||||
m := testModule(t, "input-vars")
|
||||
|
Loading…
Reference in New Issue
Block a user