|
6 | 6 |
|
7 | 7 | "github.com/google/go-cmp/cmp"
|
8 | 8 | "github.com/hashicorp/terraform-plugin-framework/attr"
|
| 9 | + testtypes "github.com/hashicorp/terraform-plugin-framework/internal/testing/types" |
9 | 10 | "github.com/hashicorp/terraform-plugin-framework/types"
|
10 | 11 | "github.com/hashicorp/terraform-plugin-go/tfprotov6"
|
11 | 12 | "github.com/hashicorp/terraform-plugin-go/tftypes"
|
@@ -867,6 +868,60 @@ func TestAttributeValidate(t *testing.T) {
|
867 | 868 | },
|
868 | 869 | },
|
869 | 870 | },
|
| 871 | + "type-with-validate-error": { |
| 872 | + req: ValidateAttributeRequest{ |
| 873 | + AttributePath: tftypes.NewAttributePath().WithAttributeName("test"), |
| 874 | + Config: Config{ |
| 875 | + Raw: tftypes.NewValue(tftypes.Object{ |
| 876 | + AttributeTypes: map[string]tftypes.Type{ |
| 877 | + "test": tftypes.String, |
| 878 | + }, |
| 879 | + }, map[string]tftypes.Value{ |
| 880 | + "test": tftypes.NewValue(tftypes.String, "testvalue"), |
| 881 | + }), |
| 882 | + Schema: Schema{ |
| 883 | + Attributes: map[string]Attribute{ |
| 884 | + "test": { |
| 885 | + Type: testtypes.StringTypeWithValidateError{}, |
| 886 | + Required: true, |
| 887 | + }, |
| 888 | + }, |
| 889 | + }, |
| 890 | + }, |
| 891 | + }, |
| 892 | + resp: ValidateAttributeResponse{ |
| 893 | + Diagnostics: []*tfprotov6.Diagnostic{ |
| 894 | + testtypes.TestErrorDiagnostic, |
| 895 | + }, |
| 896 | + }, |
| 897 | + }, |
| 898 | + "type-with-validate-warning": { |
| 899 | + req: ValidateAttributeRequest{ |
| 900 | + AttributePath: tftypes.NewAttributePath().WithAttributeName("test"), |
| 901 | + Config: Config{ |
| 902 | + Raw: tftypes.NewValue(tftypes.Object{ |
| 903 | + AttributeTypes: map[string]tftypes.Type{ |
| 904 | + "test": tftypes.String, |
| 905 | + }, |
| 906 | + }, map[string]tftypes.Value{ |
| 907 | + "test": tftypes.NewValue(tftypes.String, "testvalue"), |
| 908 | + }), |
| 909 | + Schema: Schema{ |
| 910 | + Attributes: map[string]Attribute{ |
| 911 | + "test": { |
| 912 | + Type: testtypes.StringTypeWithValidateWarning{}, |
| 913 | + Required: true, |
| 914 | + }, |
| 915 | + }, |
| 916 | + }, |
| 917 | + }, |
| 918 | + }, |
| 919 | + resp: ValidateAttributeResponse{ |
| 920 | + Diagnostics: []*tfprotov6.Diagnostic{ |
| 921 | + testtypes.TestWarningDiagnostic, |
| 922 | + }, |
| 923 | + }, |
| 924 | + }, |
870 | 925 | "nested-attr-list-no-validation": {
|
871 | 926 | req: ValidateAttributeRequest{
|
872 | 927 | AttributePath: tftypes.NewAttributePath().WithAttributeName("test"),
|
|
0 commit comments