mirror of
https://github.com/opentofu/opentofu.git
synced 2024-12-27 09:21:14 -06:00
52 lines
1.2 KiB
Go
52 lines
1.2 KiB
Go
package structure
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func TestSuppressJsonDiff_same(t *testing.T) {
|
|
original := `{ "enabled": true }`
|
|
new := `{ "enabled": true }`
|
|
expected := true
|
|
|
|
actual := SuppressJsonDiff("test", original, new, nil)
|
|
if actual != expected {
|
|
t.Fatal("[ERROR] Identical JSON values shouldn't cause a diff")
|
|
}
|
|
}
|
|
|
|
func TestSuppressJsonDiff_sameWithWhitespace(t *testing.T) {
|
|
original := `{
|
|
"enabled": true
|
|
}`
|
|
new := `{ "enabled": true }`
|
|
expected := true
|
|
|
|
actual := SuppressJsonDiff("test", original, new, nil)
|
|
if actual != expected {
|
|
t.Fatal("[ERROR] Identical JSON values shouldn't cause a diff")
|
|
}
|
|
}
|
|
|
|
func TestSuppressJsonDiff_differentValue(t *testing.T) {
|
|
original := `{ "enabled": true }`
|
|
new := `{ "enabled": false }`
|
|
expected := false
|
|
|
|
actual := SuppressJsonDiff("test", original, new, nil)
|
|
if actual != expected {
|
|
t.Fatal("[ERROR] Different JSON values should cause a diff")
|
|
}
|
|
}
|
|
|
|
func TestSuppressJsonDiff_newValue(t *testing.T) {
|
|
original := `{ "enabled": true }`
|
|
new := `{ "enabled": false, "world": "round" }`
|
|
expected := false
|
|
|
|
actual := SuppressJsonDiff("test", original, new, nil)
|
|
if actual != expected {
|
|
t.Fatal("[ERROR] Different JSON values should cause a diff")
|
|
}
|
|
}
|