Rework tree from map (#139)

* Make TreeFromMap reflect to construct tree
* Fix wording of invalid value type in writeTo

Fixes #138, #139, #134 

⚠️ TreeFromMap signature changed to `TreeFromMap(map[string]interface{}) (*TomlTree, error)`
This commit is contained in:
Thomas Pelletier
2017-03-14 13:16:40 -07:00
committed by GitHub
parent 3b00596b2e
commit fee7787d3f
7 changed files with 240 additions and 13 deletions
+5 -2
View File
@@ -121,8 +121,11 @@ func TestTomlQuery(t *testing.T) {
func TestTomlFromMap(t *testing.T) {
simpleMap := map[string]interface{}{"hello": 42}
tree := TreeFromMap(simpleMap)
if tree.Get("hello") != 42 {
tree, err := TreeFromMap(simpleMap)
if err != nil {
t.Fatal("unexpected error:", err)
}
if tree.Get("hello") != int64(42) {
t.Fatal("hello should be 42, not", tree.Get("hello"))
}
}