core: fix TestContext2Apply_outputDiffVars
There were two problems with this test as originally written: - Its ApplyFn was handling a destroy diff by returning a new object, and thus not actually destroying the object in question at all. - It was treating unknown values in the diff as invalid during apply, but these are in fact now expected as a way for the provider to distinguish whether an optional+computed attribute is set in config. With those changes in mind, this test isn't really testing anything special anymore, but is still a straightforward test of a simple plan+apply running to completion without error.
This commit is contained in:
parent
19a3095c0d
commit
5678e94021
|
@ -5841,7 +5841,7 @@ func TestContext2Apply_outputDiffVars(t *testing.T) {
|
|||
&ModuleState{
|
||||
Path: rootModulePath,
|
||||
Resources: map[string]*ResourceState{
|
||||
"aws_instance.baz": &ResourceState{
|
||||
"aws_instance.baz": &ResourceState{ // This one is not in config, so should be destroyed
|
||||
Type: "aws_instance",
|
||||
Primary: &InstanceState{
|
||||
ID: "bar",
|
||||
|
@ -5862,10 +5862,8 @@ func TestContext2Apply_outputDiffVars(t *testing.T) {
|
|||
})
|
||||
|
||||
p.ApplyFn = func(info *InstanceInfo, s *InstanceState, d *InstanceDiff) (*InstanceState, error) {
|
||||
for k, ad := range d.Attributes {
|
||||
if ad.NewComputed {
|
||||
return nil, fmt.Errorf("%s: computed", k)
|
||||
}
|
||||
if d.Destroy {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
result := s.MergeDiff(d)
|
||||
|
@ -5888,10 +5886,12 @@ func TestContext2Apply_outputDiffVars(t *testing.T) {
|
|||
}
|
||||
|
||||
if _, diags := ctx.Plan(); diags.HasErrors() {
|
||||
t.Fatalf("plan errors: %s", diags.Err())
|
||||
logDiagnostics(t, diags)
|
||||
t.Fatal("plan failed")
|
||||
}
|
||||
if _, diags := ctx.Apply(); diags.HasErrors() {
|
||||
t.Fatalf("apply errors: %s", diags.Err())
|
||||
logDiagnostics(t, diags)
|
||||
t.Fatal("apply failed")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue