@@ -314,3 +314,31 @@ func Test_HCty_ToX(t *testing.T) {
314314 assert .Equal (t , 42.41 , valueshim .FromHCtyValue (cty .NumberFloatVal (42.41 )).NumberValue ())
315315 assert .Equal (t , true , valueshim .FromHCtyValue (cty .BoolVal (true )).BoolValue ())
316316}
317+
318+ func Test_HCtyType_AttributeType (t * testing.T ) {
319+ objTy := cty .Object (map [string ]cty.Type {"x" : cty .String })
320+
321+ ty , ok := valueshim .FromHCtyType (objTy ).AttributeType ("x" )
322+ assert .True (t , ok )
323+ assert .Equal (t , valueshim .FromHCtyType (cty .String ), ty )
324+
325+ _ , ok = valueshim .FromHCtyType (objTy ).AttributeType ("y" )
326+ assert .False (t , ok )
327+ }
328+
329+ func Test_HCtyType_ElementType (t * testing.T ) {
330+ ty , ok := valueshim .FromHCtyType (cty .Set (cty .Number )).ElementType ()
331+ assert .True (t , ok )
332+ assert .Equal (t , valueshim .FromHCtyType (cty .Number ), ty )
333+
334+ ty , ok = valueshim .FromHCtyType (cty .List (cty .Number )).ElementType ()
335+ assert .True (t , ok )
336+ assert .Equal (t , valueshim .FromHCtyType (cty .Number ), ty )
337+
338+ ty , ok = valueshim .FromHCtyType (cty .Map (cty .Number )).ElementType ()
339+ assert .True (t , ok )
340+ assert .Equal (t , valueshim .FromHCtyType (cty .Number ), ty )
341+
342+ ty , ok = valueshim .FromHCtyType (cty .String ).ElementType ()
343+ assert .False (t , ok )
344+ }
0 commit comments