@@ -2783,6 +2783,91 @@ func TestServerPlanResourceChange(t *testing.T) {
2783
2783
PlannedPrivate : testEmptyPrivate ,
2784
2784
},
2785
2785
},
2786
+ "create-resourcewithmodifyplan-request-client-capabilities-deferral-allowed" : {
2787
+ server : & fwserver.Server {
2788
+ Provider : & testprovider.Provider {},
2789
+ },
2790
+ request : & fwserver.PlanResourceChangeRequest {
2791
+ ClientCapabilities : testDeferralAllowed ,
2792
+ Config : & tfsdk.Config {
2793
+ Raw : tftypes .NewValue (testSchemaType , map [string ]tftypes.Value {
2794
+ "test_computed" : tftypes .NewValue (tftypes .String , nil ),
2795
+ "test_required" : tftypes .NewValue (tftypes .String , "test-config-value" ),
2796
+ }),
2797
+ Schema : testSchema ,
2798
+ },
2799
+ ProposedNewState : & tfsdk.Plan {
2800
+ Raw : tftypes .NewValue (testSchemaType , map [string ]tftypes.Value {
2801
+ "test_computed" : tftypes .NewValue (tftypes .String , nil ),
2802
+ "test_required" : tftypes .NewValue (tftypes .String , "test-config-value" ),
2803
+ }),
2804
+ Schema : testSchema ,
2805
+ },
2806
+ PriorState : testEmptyState ,
2807
+ ResourceSchema : testSchema ,
2808
+ Resource : & testprovider.ResourceWithModifyPlan {
2809
+ ModifyPlanMethod : func (ctx context.Context , req resource.ModifyPlanRequest , resp * resource.ModifyPlanResponse ) {
2810
+ if req .ClientCapabilities .DeferralAllowed != true {
2811
+ resp .Diagnostics .AddError ("Unexpected req.ClientCapabilities.DeferralAllowed value" ,
2812
+ "expected: true but got: false" )
2813
+ }
2814
+
2815
+ },
2816
+ },
2817
+ },
2818
+ expectedResponse : & fwserver.PlanResourceChangeResponse {
2819
+ PlannedState : & tfsdk.State {
2820
+ Raw : tftypes .NewValue (testSchemaType , map [string ]tftypes.Value {
2821
+ "test_computed" : tftypes .NewValue (tftypes .String , tftypes .UnknownValue ),
2822
+ "test_required" : tftypes .NewValue (tftypes .String , "test-config-value" ),
2823
+ }),
2824
+ Schema : testSchema ,
2825
+ },
2826
+ PlannedPrivate : testEmptyPrivate ,
2827
+ },
2828
+ },
2829
+ "create-resourcewithmodifyplan-request-client-capabilities-unset" : {
2830
+ server : & fwserver.Server {
2831
+ Provider : & testprovider.Provider {},
2832
+ },
2833
+ request : & fwserver.PlanResourceChangeRequest {
2834
+ Config : & tfsdk.Config {
2835
+ Raw : tftypes .NewValue (testSchemaType , map [string ]tftypes.Value {
2836
+ "test_computed" : tftypes .NewValue (tftypes .String , nil ),
2837
+ "test_required" : tftypes .NewValue (tftypes .String , "test-config-value" ),
2838
+ }),
2839
+ Schema : testSchema ,
2840
+ },
2841
+ ProposedNewState : & tfsdk.Plan {
2842
+ Raw : tftypes .NewValue (testSchemaType , map [string ]tftypes.Value {
2843
+ "test_computed" : tftypes .NewValue (tftypes .String , nil ),
2844
+ "test_required" : tftypes .NewValue (tftypes .String , "test-config-value" ),
2845
+ }),
2846
+ Schema : testSchema ,
2847
+ },
2848
+ PriorState : testEmptyState ,
2849
+ ResourceSchema : testSchema ,
2850
+ Resource : & testprovider.ResourceWithModifyPlan {
2851
+ ModifyPlanMethod : func (ctx context.Context , req resource.ModifyPlanRequest , resp * resource.ModifyPlanResponse ) {
2852
+ if req .ClientCapabilities .DeferralAllowed != false {
2853
+ resp .Diagnostics .AddError ("Unexpected req.ClientCapabilities.DeferralAllowed value" ,
2854
+ "expected: false but got: true" )
2855
+ }
2856
+
2857
+ },
2858
+ },
2859
+ },
2860
+ expectedResponse : & fwserver.PlanResourceChangeResponse {
2861
+ PlannedState : & tfsdk.State {
2862
+ Raw : tftypes .NewValue (testSchemaType , map [string ]tftypes.Value {
2863
+ "test_computed" : tftypes .NewValue (tftypes .String , tftypes .UnknownValue ),
2864
+ "test_required" : tftypes .NewValue (tftypes .String , "test-config-value" ),
2865
+ }),
2866
+ Schema : testSchema ,
2867
+ },
2868
+ PlannedPrivate : testEmptyPrivate ,
2869
+ },
2870
+ },
2786
2871
"create-resourcewithmodifyplan-request-config" : {
2787
2872
server : & fwserver.Server {
2788
2873
Provider : & testprovider.Provider {},
@@ -2964,6 +3049,49 @@ func TestServerPlanResourceChange(t *testing.T) {
2964
3049
PlannedPrivate : testEmptyPrivate ,
2965
3050
},
2966
3051
},
3052
+ "create-resourcewithmodifyplan-response-deferral" : {
3053
+ server : & fwserver.Server {
3054
+ Provider : & testprovider.Provider {},
3055
+ },
3056
+ request : & fwserver.PlanResourceChangeRequest {
3057
+ ClientCapabilities : testDeferralAllowed ,
3058
+ Config : & tfsdk.Config {
3059
+ Raw : tftypes .NewValue (testSchemaType , map [string ]tftypes.Value {
3060
+ "test_computed" : tftypes .NewValue (tftypes .String , nil ),
3061
+ "test_required" : tftypes .NewValue (tftypes .String , "test-config-value" ),
3062
+ }),
3063
+ Schema : testSchema ,
3064
+ },
3065
+ ProposedNewState : & tfsdk.Plan {
3066
+ Raw : tftypes .NewValue (testSchemaType , map [string ]tftypes.Value {
3067
+ "test_computed" : tftypes .NewValue (tftypes .String , nil ),
3068
+ "test_required" : tftypes .NewValue (tftypes .String , "test-config-value" ),
3069
+ }),
3070
+ Schema : testSchema ,
3071
+ },
3072
+ PriorState : testEmptyState ,
3073
+ ResourceSchema : testSchema ,
3074
+ Resource : & testprovider.ResourceWithModifyPlan {
3075
+ ModifyPlanMethod : func (ctx context.Context , req resource.ModifyPlanRequest , resp * resource.ModifyPlanResponse ) {
3076
+ if req .ClientCapabilities .DeferralAllowed == true {
3077
+ resp .Deferred = & resource.Deferred {Reason : resource .DeferredReasonAbsentPrereq }
3078
+ }
3079
+
3080
+ },
3081
+ },
3082
+ },
3083
+ expectedResponse : & fwserver.PlanResourceChangeResponse {
3084
+ Deferred : & resource.Deferred {Reason : resource .DeferredReasonAbsentPrereq },
3085
+ PlannedState : & tfsdk.State {
3086
+ Raw : tftypes .NewValue (testSchemaType , map [string ]tftypes.Value {
3087
+ "test_computed" : tftypes .NewValue (tftypes .String , tftypes .UnknownValue ),
3088
+ "test_required" : tftypes .NewValue (tftypes .String , "test-config-value" ),
3089
+ }),
3090
+ Schema : testSchema ,
3091
+ },
3092
+ PlannedPrivate : testEmptyPrivate ,
3093
+ },
3094
+ },
2967
3095
"create-resourcewithmodifyplan-response-diagnostics" : {
2968
3096
server : & fwserver.Server {
2969
3097
Provider : & testprovider.Provider {},
@@ -6019,49 +6147,6 @@ func TestServerPlanResourceChange(t *testing.T) {
6019
6147
PlannedPrivate : testPrivateProvider ,
6020
6148
},
6021
6149
},
6022
- "create-resourcewithmodifyplan-response-deferral" : {
6023
- server : & fwserver.Server {
6024
- Provider : & testprovider.Provider {},
6025
- },
6026
- request : & fwserver.PlanResourceChangeRequest {
6027
- ClientCapabilities : testDeferralAllowed ,
6028
- Config : & tfsdk.Config {
6029
- Raw : tftypes .NewValue (testSchemaType , map [string ]tftypes.Value {
6030
- "test_computed" : tftypes .NewValue (tftypes .String , nil ),
6031
- "test_required" : tftypes .NewValue (tftypes .String , "test-config-value" ),
6032
- }),
6033
- Schema : testSchema ,
6034
- },
6035
- ProposedNewState : & tfsdk.Plan {
6036
- Raw : tftypes .NewValue (testSchemaType , map [string ]tftypes.Value {
6037
- "test_computed" : tftypes .NewValue (tftypes .String , nil ),
6038
- "test_required" : tftypes .NewValue (tftypes .String , "test-config-value" ),
6039
- }),
6040
- Schema : testSchema ,
6041
- },
6042
- PriorState : testEmptyState ,
6043
- ResourceSchema : testSchema ,
6044
- Resource : & testprovider.ResourceWithModifyPlan {
6045
- ModifyPlanMethod : func (ctx context.Context , req resource.ModifyPlanRequest , resp * resource.ModifyPlanResponse ) {
6046
- if req .ClientCapabilities .DeferralAllowed == true {
6047
- resp .Deferred = & resource.Deferred {Reason : resource .DeferredReasonAbsentPrereq }
6048
- }
6049
-
6050
- },
6051
- },
6052
- },
6053
- expectedResponse : & fwserver.PlanResourceChangeResponse {
6054
- Deferred : & resource.Deferred {Reason : resource .DeferredReasonAbsentPrereq },
6055
- PlannedState : & tfsdk.State {
6056
- Raw : tftypes .NewValue (testSchemaType , map [string ]tftypes.Value {
6057
- "test_computed" : tftypes .NewValue (tftypes .String , tftypes .UnknownValue ),
6058
- "test_required" : tftypes .NewValue (tftypes .String , "test-config-value" ),
6059
- }),
6060
- Schema : testSchema ,
6061
- },
6062
- PlannedPrivate : testEmptyPrivate ,
6063
- },
6064
- },
6065
6150
}
6066
6151
6067
6152
for name , testCase := range testCases {
0 commit comments