Skip to content

Commit

Permalink
chore: add UnmarshalKey test case
Browse files Browse the repository at this point in the history
  • Loading branch information
sysulq committed Feb 17, 2023
1 parent 28dc8d0 commit a82bb7f
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions pkg/conf/conf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,28 @@ func TestConf(t *testing.T) {
if addr.Addr != "localhost" {
t.Fatal("unmarshal failed")
}

type Cfg struct {
Server struct {
HTTP struct {
Addr Addr
}
}
}

cfg := Cfg{}
err = UnmarshalKey("", &cfg)
if err != nil {
t.Fatal(err)
}

if cfg.Server.HTTP.Addr.Port != 8080 {
t.Fatal("unmarshal failed")
}

if cfg.Server.HTTP.Addr.Addr != "localhost" {
t.Fatal("unmarshal failed")
}
})
}

Expand Down

0 comments on commit a82bb7f

Please sign in to comment.