@@ -6,14 +6,28 @@ import (
66
77 "github.com/dineshba/tf-summarize/terraformstate"
88 "github.com/stretchr/testify/assert"
9+
10+ . "github.com/hashicorp/terraform-json"
911)
1012
1113func TestTableWriter_Write_NoMarkdown (t * testing.T ) {
1214 changes := createMockChanges ()
1315
16+ changes ["update" ] = terraformstate.ResourceChanges {
17+ {
18+ Address : "aws_instance.example3" ,
19+ Change : & Change {Actions : Actions {ActionUpdate }},
20+ },
21+ {
22+ Address : "aws_instance.example4.tag[\" Custom Instance Tag\" ]" ,
23+ Change : & Change {Actions : Actions {ActionUpdate }},
24+ },
25+ }
26+
1427 outputChanges := map [string ][]string {
1528 "update" : {
1629 "output.example" ,
30+ "output.long_resource_name.this[\" Custom/Resource Name\" ]" ,
1731 },
1832 }
1933
@@ -22,18 +36,24 @@ func TestTableWriter_Write_NoMarkdown(t *testing.T) {
2236 err := tw .Write (& output )
2337 assert .NoError (t , err )
2438
25- expectedOutput := `+--------+-----------------------+
26- | CHANGE | RESOURCE |
27- +--------+-----------------------+
28- | add | aws_instance.example1 |
29- +--------+-----------------------+
30- | delete | aws_instance.example2 |
31- +--------+-----------------------+
32- +--------+----------------+
33- | CHANGE | OUTPUT |
34- +--------+----------------+
35- | update | output.example |
36- +--------+----------------+
39+ expectedOutput := `+--------+--------------------------------------------------+
40+ | CHANGE | RESOURCE |
41+ +--------+--------------------------------------------------+
42+ | add | aws_instance.example1 |
43+ +--------+--------------------------------------------------+
44+ | update | aws_instance.example3 |
45+ + +--------------------------------------------------+
46+ | | aws_instance.example4.tag["Custom Instance Tag"] |
47+ +--------+--------------------------------------------------+
48+ | delete | aws_instance.example2 |
49+ +--------+--------------------------------------------------+
50+ +--------+--------------------------------------------------------+
51+ | CHANGE | OUTPUT |
52+ +--------+--------------------------------------------------------+
53+ | update | output.example |
54+ + +--------------------------------------------------------+
55+ | | output.long_resource_name.this["Custom/Resource Name"] |
56+ +--------+--------------------------------------------------------+
3757`
3858
3959 assert .Equal (t , expectedOutput , output .String ())
@@ -45,6 +65,7 @@ func TestTableWriter_Write_WithMarkdown(t *testing.T) {
4565 outputChanges := map [string ][]string {
4666 "update" : {
4767 "output.example" ,
68+ "output.long_resource_name.this[\" Custom/Resource Name\" ]" ,
4869 },
4970 }
5071
@@ -58,9 +79,10 @@ func TestTableWriter_Write_WithMarkdown(t *testing.T) {
5879| add | ` + "`aws_instance.example1`" + ` |
5980| delete | ` + "`aws_instance.example2`" + ` |
6081
61- | CHANGE | OUTPUT |
62- |--------|------------------|
63- | update | ` + "`output.example`" + ` |
82+ | CHANGE | OUTPUT |
83+ |--------|----------------------------------------------------------|
84+ | update | ` + "`output.example`" + ` |
85+ | | ` + "`output.long_resource_name.this[\" Custom/Resource Name\" ]`" + ` |
6486`
6587
6688 assert .Equal (t , expectedOutput , output .String ())
0 commit comments