-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix comma condition and add unit test
- Loading branch information
1 parent
8bfcfd0
commit b281ac5
Showing
2 changed files
with
69 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package iac3 | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestTsMap_String(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
m TsMap | ||
want string | ||
}{ | ||
{ | ||
name: "empty map", | ||
m: TsMap{}, | ||
want: "{}", | ||
}, | ||
{ | ||
name: "map with one entry", | ||
m: TsMap{"foo": "bar"}, | ||
want: "{foo: bar}", | ||
}, | ||
{ | ||
name: "map with multiple entries", | ||
m: TsMap{"foo": "bar", "baz": "qux"}, | ||
want: "{foo: bar, baz: qux}", | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
assert.Equal(t, tt.m.String(), tt.want) | ||
}) | ||
} | ||
} | ||
|
||
func TestTsList_String(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
l TsList | ||
want string | ||
}{ | ||
{ | ||
name: "empty list", | ||
l: TsList{}, | ||
want: "[]", | ||
}, | ||
{ | ||
name: "list with one entry", | ||
l: TsList{"foo"}, | ||
want: "[foo]", | ||
}, | ||
{ | ||
name: "list with multiple entries", | ||
l: TsList{"foo", "bar"}, | ||
want: "[foo, bar]", | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
assert.Equal(t, tt.l.String(), tt.want) | ||
}) | ||
} | ||
} |