@@ -6,14 +6,14 @@ package identityschema_test
66import (
77 "context"
88 "fmt"
9+ "github.com/hashicorp/terraform-plugin-framework/diag"
910 "strings"
1011 "testing"
1112
1213 "github.com/google/go-cmp/cmp"
1314 "github.com/hashicorp/terraform-plugin-go/tftypes"
1415
1516 "github.com/hashicorp/terraform-plugin-framework/attr"
16- "github.com/hashicorp/terraform-plugin-framework/diag"
1717 "github.com/hashicorp/terraform-plugin-framework/internal/fwschema"
1818 "github.com/hashicorp/terraform-plugin-framework/internal/testing/testschema"
1919 "github.com/hashicorp/terraform-plugin-framework/internal/testing/testtypes"
@@ -480,6 +480,135 @@ func TestListAttributeValidateImplementation(t *testing.T) {
480480 },
481481 },
482482 },
483+ "elementtype-bool" : {
484+ attribute : identityschema.ListAttribute {
485+ RequiredForImport : true ,
486+ ElementType : types .BoolType ,
487+ },
488+ request : fwschema.ValidateImplementationRequest {
489+ Name : "test" ,
490+ Path : path .Root ("test" ),
491+ },
492+ expected : & fwschema.ValidateImplementationResponse {},
493+ },
494+ "elementtype-int64" : {
495+ attribute : identityschema.ListAttribute {
496+ RequiredForImport : true ,
497+ ElementType : types .Int64Type ,
498+ },
499+ request : fwschema.ValidateImplementationRequest {
500+ Name : "test" ,
501+ Path : path .Root ("test" ),
502+ },
503+ expected : & fwschema.ValidateImplementationResponse {},
504+ },
505+ "elementtype-int32" : {
506+ attribute : identityschema.ListAttribute {
507+ RequiredForImport : true ,
508+ ElementType : types .Int32Type ,
509+ },
510+ request : fwschema.ValidateImplementationRequest {
511+ Name : "test" ,
512+ Path : path .Root ("test" ),
513+ },
514+ expected : & fwschema.ValidateImplementationResponse {},
515+ },
516+ "elementtype-float64" : {
517+ attribute : identityschema.ListAttribute {
518+ RequiredForImport : true ,
519+ ElementType : types .Float64Type ,
520+ },
521+ request : fwschema.ValidateImplementationRequest {
522+ Name : "test" ,
523+ Path : path .Root ("test" ),
524+ },
525+ expected : & fwschema.ValidateImplementationResponse {},
526+ },
527+ "elementtype-float32" : {
528+ attribute : identityschema.ListAttribute {
529+ RequiredForImport : true ,
530+ ElementType : types .Float32Type ,
531+ },
532+ request : fwschema.ValidateImplementationRequest {
533+ Name : "test" ,
534+ Path : path .Root ("test" ),
535+ },
536+ expected : & fwschema.ValidateImplementationResponse {},
537+ },
538+ "elementtype-number" : {
539+ attribute : identityschema.ListAttribute {
540+ RequiredForImport : true ,
541+ ElementType : types .NumberType ,
542+ },
543+ request : fwschema.ValidateImplementationRequest {
544+ Name : "test" ,
545+ Path : path .Root ("test" ),
546+ },
547+ expected : & fwschema.ValidateImplementationResponse {},
548+ },
549+ "elementtype-notprimitive-dynamic" : {
550+ attribute : identityschema.ListAttribute {
551+ RequiredForImport : true ,
552+ ElementType : types .DynamicType ,
553+ },
554+ request : fwschema.ValidateImplementationRequest {
555+ Name : "test" ,
556+ Path : path .Root ("test" ),
557+ },
558+ expected : & fwschema.ValidateImplementationResponse {
559+ Diagnostics : diag.Diagnostics {
560+ diag .NewErrorDiagnostic (
561+ "Invalid Attribute Implementation" ,
562+ "When validating the schema, an implementation issue was found. " +
563+ "This is always an issue with the provider and should be reported to the provider developers.\n \n " +
564+ "\" test\" contains an element of type \" basetypes.DynamicType\" that is not allowed for Lists in Resource Identity. " +
565+ "Lists in Resource Identity may only have primitive element types such as Bool, Int, Float, Number and String." ,
566+ ),
567+ },
568+ },
569+ },
570+ "elementtype-notprimitive-object" : {
571+ attribute : identityschema.ListAttribute {
572+ RequiredForImport : true ,
573+ ElementType : types.ObjectType {},
574+ },
575+ request : fwschema.ValidateImplementationRequest {
576+ Name : "test" ,
577+ Path : path .Root ("test" ),
578+ },
579+ expected : & fwschema.ValidateImplementationResponse {
580+ Diagnostics : diag.Diagnostics {
581+ diag .NewErrorDiagnostic (
582+ "Invalid Attribute Implementation" ,
583+ "When validating the schema, an implementation issue was found. " +
584+ "This is always an issue with the provider and should be reported to the provider developers.\n \n " +
585+ "\" test\" contains an element of type \" types.ObjectType[]\" that is not allowed for Lists in Resource Identity. " +
586+ "Lists in Resource Identity may only have primitive element types such as Bool, Int, Float, Number and String." ,
587+ ),
588+ },
589+ },
590+ },
591+ "elementtype-notprimitive-map" : {
592+ attribute : identityschema.ListAttribute {
593+ RequiredForImport : true ,
594+ ElementType : types.MapType {},
595+ },
596+ request : fwschema.ValidateImplementationRequest {
597+ Name : "test" ,
598+ Path : path .Root ("test" ),
599+ },
600+ expected : & fwschema.ValidateImplementationResponse {
601+ Diagnostics : diag.Diagnostics {
602+ diag .NewErrorDiagnostic (
603+ "Invalid Attribute Implementation" ,
604+ "When validating the schema, an implementation issue was found. " +
605+ "This is always an issue with the provider and should be reported to the provider developers.\n \n " +
606+ "\" test\" contains an element of type \" types.MapType[!!! MISSING TYPE !!!]\" that is not allowed for Lists in Resource Identity. " +
607+ "Lists in Resource Identity may only have primitive element types such as Bool, Int, Float, Number and String." ,
608+ ),
609+ },
610+ },
611+ },
483612 }
484613
485614 for name , testCase := range testCases {
0 commit comments