@@ -34,12 +34,10 @@ func TestRenderHuman_InvokeActionPlan(t *testing.T) {
34
34
plan := Plan {
35
35
ActionInvocations : []jsonplan.ActionInvocation {
36
36
{
37
- Address : "action.test_action.action" ,
38
- Type : "test_action" ,
39
- Name : "action" ,
40
- ConfigValues : map [string ]json.RawMessage {
41
- "attr" : []byte ("\" one\" " ),
42
- },
37
+ Address : "action.test_action.action" ,
38
+ Type : "test_action" ,
39
+ Name : "action" ,
40
+ ConfigValues : json .RawMessage ("{\" attr\" :\" one\" }" ),
43
41
ConfigSensitive : nil ,
44
42
ProviderName : "test" ,
45
43
InvokeActionTrigger : new (jsonplan.InvokeActionTrigger ),
@@ -95,12 +93,10 @@ func TestRenderHuman_InvokeActionPlanWithRefresh(t *testing.T) {
95
93
plan := Plan {
96
94
ActionInvocations : []jsonplan.ActionInvocation {
97
95
{
98
- Address : "action.test_action.action" ,
99
- Type : "test_action" ,
100
- Name : "action" ,
101
- ConfigValues : map [string ]json.RawMessage {
102
- "attr" : []byte ("\" one\" " ),
103
- },
96
+ Address : "action.test_action.action" ,
97
+ Type : "test_action" ,
98
+ Name : "action" ,
99
+ ConfigValues : json .RawMessage ("{\" attr\" :\" one\" }" ),
104
100
ConfigSensitive : nil ,
105
101
ProviderName : "test" ,
106
102
InvokeActionTrigger : new (jsonplan.InvokeActionTrigger ),
@@ -8483,7 +8479,7 @@ func TestResourceChange_actions(t *testing.T) {
8483
8479
TriggeringResourceAddress : triggeringResourceAddr .String (),
8484
8480
ActionTriggerEvent : "BeforeCreate" ,
8485
8481
},
8486
- ConfigValues : marshalConfigValues ( cty .ObjectVal (map [string ]cty.Value {
8482
+ ConfigValues : marshalCtyJson ( t , cty .ObjectVal (map [string ]cty.Value {
8487
8483
"id" : cty .StringVal ("1D5F5E9E-F2E5-401B-9ED5-692A215AC67E" ),
8488
8484
"disk" : cty .ObjectVal (map [string ]cty.Value {
8489
8485
"size" : cty .StringVal ("100" ),
@@ -8527,7 +8523,7 @@ func TestResourceChange_actions(t *testing.T) {
8527
8523
TriggeringResourceAddress : triggeringResourceAddr .String (),
8528
8524
ActionTriggerEvent : "AfterCreate" ,
8529
8525
},
8530
- ConfigValues : marshalConfigValues ( cty .ObjectVal (map [string ]cty.Value {
8526
+ ConfigValues : marshalCtyJson ( t , cty .ObjectVal (map [string ]cty.Value {
8531
8527
"id" : cty .StringVal ("1D5F5E9E-F2E5-401B-9ED5-692A215AC67E" ),
8532
8528
"disk" : cty .ObjectVal (map [string ]cty.Value {
8533
8529
"size" : cty .StringVal ("100" ),
@@ -8571,7 +8567,7 @@ func TestResourceChange_actions(t *testing.T) {
8571
8567
TriggeringResourceAddress : triggeringResourceAddr .String (),
8572
8568
ActionTriggerEvent : "BeforeCreate" ,
8573
8569
},
8574
- ConfigValues : marshalConfigValues ( cty .ObjectVal (map [string ]cty.Value {
8570
+ ConfigValues : marshalCtyJson ( t , cty .ObjectVal (map [string ]cty.Value {
8575
8571
"id" : cty .StringVal ("first-block-and-action" ),
8576
8572
})),
8577
8573
},
@@ -8586,7 +8582,7 @@ func TestResourceChange_actions(t *testing.T) {
8586
8582
TriggeringResourceAddress : triggeringResourceAddr .String (),
8587
8583
ActionTriggerEvent : "BeforeCreate" ,
8588
8584
},
8589
- ConfigValues : marshalConfigValues ( cty .ObjectVal (map [string ]cty.Value {
8585
+ ConfigValues : marshalCtyJson ( t , cty .ObjectVal (map [string ]cty.Value {
8590
8586
"id" : cty .StringVal ("first-block-second-action" ),
8591
8587
})),
8592
8588
},
@@ -8601,7 +8597,7 @@ func TestResourceChange_actions(t *testing.T) {
8601
8597
TriggeringResourceAddress : triggeringResourceAddr .String (),
8602
8598
ActionTriggerEvent : "AfterCreate" ,
8603
8599
},
8604
- ConfigValues : marshalConfigValues ( cty .ObjectVal (map [string ]cty.Value {
8600
+ ConfigValues : marshalCtyJson ( t , cty .ObjectVal (map [string ]cty.Value {
8605
8601
"id" : cty .StringVal ("second-block-first-action" ),
8606
8602
})),
8607
8603
},
@@ -8616,7 +8612,7 @@ func TestResourceChange_actions(t *testing.T) {
8616
8612
TriggeringResourceAddress : triggeringResourceAddr .String (),
8617
8613
ActionTriggerEvent : "AfterCreate" ,
8618
8614
},
8619
- ConfigValues : marshalConfigValues ( cty .ObjectVal (map [string ]cty.Value {
8615
+ ConfigValues : marshalCtyJson ( t , cty .ObjectVal (map [string ]cty.Value {
8620
8616
"id" : cty .StringVal ("third-block-first-action" ),
8621
8617
})),
8622
8618
},
@@ -8631,7 +8627,7 @@ func TestResourceChange_actions(t *testing.T) {
8631
8627
TriggeringResourceAddress : triggeringResourceAddr .String (),
8632
8628
ActionTriggerEvent : "BeforeCreate" ,
8633
8629
},
8634
- ConfigValues : marshalConfigValues ( cty .ObjectVal (map [string ]cty.Value {
8630
+ ConfigValues : marshalCtyJson ( t , cty .ObjectVal (map [string ]cty.Value {
8635
8631
"id" : cty .StringVal ("fourth-block-first-action" ),
8636
8632
})),
8637
8633
},
@@ -8739,23 +8735,6 @@ func TestResourceChange_actions(t *testing.T) {
8739
8735
})
8740
8736
}
8741
8737
}
8742
- func marshalConfigValues (value cty.Value ) map [string ]json.RawMessage {
8743
- // unmark our value to show all values
8744
- v , _ := value .UnmarkDeep ()
8745
-
8746
- if v == cty .NilVal || v .IsNull () {
8747
- return nil
8748
- }
8749
-
8750
- ret := make (map [string ]json.RawMessage )
8751
- it := value .ElementIterator ()
8752
- for it .Next () {
8753
- k , v := it .Element ()
8754
- vJSON , _ := ctyjson .Marshal (v , v .Type ())
8755
- ret [k .AsString ()] = json .RawMessage (vJSON )
8756
- }
8757
- return ret
8758
- }
8759
8738
8760
8739
func outputChange (name string , before , after cty.Value , sensitive bool ) * plans.OutputChangeSrc {
8761
8740
addr := addrs.AbsOutputValue {
@@ -8931,3 +8910,11 @@ func marshalJson(t *testing.T, data interface{}) json.RawMessage {
8931
8910
}
8932
8911
return result
8933
8912
}
8913
+
8914
+ func marshalCtyJson (t * testing.T , data cty.Value ) json.RawMessage {
8915
+ result , err := ctyjson .Marshal (data , data .Type ())
8916
+ if err != nil {
8917
+ t .Fatalf ("failed to marshal json: %v" , err )
8918
+ }
8919
+ return result
8920
+ }
0 commit comments