Skip to content

Commit

Permalink
add missing test case for immutable list plan modifier
Browse files Browse the repository at this point in the history
  • Loading branch information
ctreatma committed Mar 20, 2024
1 parent ec85ea8 commit 92e2f47
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions internal/planmodifiers/immutable_list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,25 @@ import (

func TestImmutableListSet(t *testing.T) {
testCases := []struct {
Old, New, Expected []string
ExpectError bool
Old, New, Expected []string
ExpectError bool
}{
{
Old: []string{},
New: []string{"test"},
Expected: []string{"test"},
Old: []string{},
New: []string{"test"},
Expected: []string{"test"},
ExpectError: false,
},
{
Old: []string{"test"},
New: []string{},
Expected: []string{},
Old: []string{"test"},
New: []string{},
Expected: []string{},
ExpectError: true,
},
{
Old: []string{"foo"},
New: []string{"bar"},
Expected: []string{"bar"},
ExpectError: true,
},
}
Expand All @@ -38,7 +44,7 @@ func TestImmutableListSet(t *testing.T) {
req := planmodifier.ListRequest{
StateValue: stateValue,
PlanValue: planValue,
Path: path.Root("test"),
Path: path.Root("test"),
}

var resp planmodifier.ListResponse
Expand All @@ -52,8 +58,8 @@ func TestImmutableListSet(t *testing.T) {
}

if !resp.PlanValue.Equal(expectedValue) {
value, _:= resp.PlanValue.ToListValue(context.Background())
value, _ := resp.PlanValue.ToListValue(context.Background())
t.Fatalf("%d: output plan value does not equal expected. Want %v plan value, got %v", i, expectedValue, value)
}
}
}
}

0 comments on commit 92e2f47

Please sign in to comment.