add decoding tests for trilean

This commit is contained in:
Adrien Delorme 2019-08-23 12:01:28 +02:00
parent 2efc94521b
commit db880ab50a
1 changed files with 19 additions and 4 deletions

View File

@ -13,6 +13,7 @@ func TestDecode(t *testing.T) {
Name string
Address string
Time time.Duration
Trilean Trilean
}
cases := map[string]struct {
@ -23,13 +24,27 @@ func TestDecode(t *testing.T) {
"basic": {
[]interface{}{
map[string]interface{}{
"name": "bar",
"time": "5s",
"name": "bar",
"time": "5s",
"trilean": "true",
},
},
&Target{
Name: "bar",
Time: 5 * time.Second,
Name: "bar",
Time: 5 * time.Second,
Trilean: TriTrue,
},
nil,
},
"empty-string-trilean": {
[]interface{}{
map[string]interface{}{
"trilean": "",
},
},
&Target{
Trilean: TriUnset,
},
nil,
},