-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature: differentiate between (+/-) and (-/+) in output (#59)
* Feature: differentiate between (+/-) and (-/+) in output * Apply linter suggestions * Update go to v1.21 * Update gh actions to go v1.21 * Fix build * Whoops
- Loading branch information
1 parent
c4f1426
commit 5c19269
Showing
5 changed files
with
80 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
module github.com/dineshba/tf-summarize | ||
|
||
go 1.20 | ||
go 1.21 | ||
|
||
require ( | ||
github.com/fatih/color v1.15.0 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package terraformstate | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestResourceChangeColor(t *testing.T) { | ||
ExpectedColors := map[string]string{ | ||
"create": ColorGreen, | ||
"delete": ColorRed, | ||
"update": ColorYellow, | ||
} | ||
|
||
for action, expectedColor := range ExpectedColors { | ||
create := ResourceChange{Change: Change{Actions: []string{action}}} | ||
color, _ := create.ColorPrefixAndSuffixText() | ||
|
||
assert.Equal(t, color, expectedColor) | ||
} | ||
create := ResourceChange{Change: Change{Actions: []string{"create", "delete"}}} | ||
color, _ := create.ColorPrefixAndSuffixText() | ||
assert.Equal(t, color, ColorMagenta) | ||
|
||
create = ResourceChange{Change: Change{Actions: []string{"delete", "create"}}} | ||
color, _ = create.ColorPrefixAndSuffixText() | ||
assert.Equal(t, color, ColorMagenta) | ||
} | ||
|
||
func TestResourceChangeSuffix(t *testing.T) { | ||
ExpectedSuffix := map[string]string{ | ||
"create": "(+)", | ||
"delete": "(-)", | ||
"update": "(~)", | ||
} | ||
|
||
for action, expectedSuffix := range ExpectedSuffix { | ||
create := ResourceChange{Change: Change{Actions: []string{action}}} | ||
_, suffix := create.ColorPrefixAndSuffixText() | ||
|
||
assert.Equal(t, suffix, expectedSuffix) | ||
} | ||
create := ResourceChange{Change: Change{Actions: []string{"create", "delete"}}} | ||
_, suffix := create.ColorPrefixAndSuffixText() | ||
assert.Equal(t, suffix, "(+/-)") | ||
|
||
create = ResourceChange{Change: Change{Actions: []string{"delete", "create"}}} | ||
_, suffix = create.ColorPrefixAndSuffixText() | ||
assert.Equal(t, suffix, "(-/+)") | ||
} | ||
|
||
func TestResourceChangeColorAndSuffixImport(t *testing.T) { | ||
importing := ResourceChange{Change: Change{Importing: Importing{ID: "id"}}} | ||
color, suffix := importing.ColorPrefixAndSuffixText() | ||
|
||
assert.Equal(t, color, ColorCyan) | ||
assert.Equal(t, suffix, "(i)") | ||
} |