Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
philchia committed Dec 27, 2018
1 parent 7333c5f commit ec65db7
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions cache_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package agollo

import (
"fmt"
"io/ioutil"
"os"
"testing"
Expand Down Expand Up @@ -64,11 +65,14 @@ func TestCacheDump(t *testing.T) {
t.FailNow()
}

}

func TestDecode(t *testing.T) {
// decode
type client struct {
type Client struct {
APP struct {
Key string `mapstructure:"key"`
} `mapstructure:"application`
} `mapstructure:"application"`
Client1 struct {
Name string `mapstructure:"name"`
} `mapstructure:"client.json"`
Expand All @@ -81,11 +85,14 @@ func TestCacheDump(t *testing.T) {
mc.mustGetCache("application").set("key", "val")
mc.mustGetCache("client.json").set("content", `{"name":"json"}`)
mc.mustGetCache("client.yaml").set("content", "name: yaml")
var c client
var c Client
if err := mc.decode(&c); err != nil {
t.FailNow()
t.Error(err)
}

fmt.Printf("%+v", c)
if c.APP.Key != "val" || c.Client1.Name != "json" || c.Client2.Name != "yaml" {
t.Error(err)
t.FailNow()
}

}

0 comments on commit ec65db7

Please sign in to comment.