Skip to content

Commit

Permalink
feat(uuidtypes): adds support for `github.com/hashicorp/terraform-plu…
Browse files Browse the repository at this point in the history
…gin-framework@v0.14.0`.
  • Loading branch information
matthewhartstonge committed Oct 5, 2022
1 parent beee762 commit ef1fcf5
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
5 changes: 5 additions & 0 deletions uuidtypes/uuid_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,8 @@ func (u UUIDType) ValueFromTerraform(_ context.Context, value tftypes.Value) (at

return UUIDFromGoogleUUID(parsedUUID), nil
}

// ValueType returns attr.Value type returned by ValueFromTerraform.
func (u UUIDType) ValueType(context.Context) attr.Value {
return UUID{}
}
34 changes: 34 additions & 0 deletions uuidtypes/uuid_type_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -412,3 +412,37 @@ func TestType_ValueFromTerraform(t *testing.T) {
})
}
}

func TestUUIDType_ValueType(t *testing.T) {
t.Parallel()

tests := []struct {
name string
value uuidtypes.UUIDType
expected attr.Value
}{
{
name: "always",
value: uuidtypes.UUIDType{},
expected: uuidtypes.UUID{},
},
}
for _, testcase := range tests {
testcase := testcase

t.Run(testcase.name, func(t *testing.T) {
t.Parallel()

got := testcase.value.ValueType(context.Background())

if diff := cmp.Diff(got, testcase.expected); diff != "" {
t.Errorf(
"Type()\ngot : %v\nexpected: %v\ndiff: %v\n",
got,
testcase.expected,
diff,
)
}
})
}
}

0 comments on commit ef1fcf5

Please sign in to comment.