Viper stores Permalinks as a map[string]interface{}, so the type assertion
to PermalinkOverrides (map[string]PathPattern) will always fail.
We can, however, get Permalinks as a map[string]string, and convert each
value to a PathPattern.
params = make(map[string]interface{})
}
- permalinks, ok := viper.Get("Permalinks").(PermalinkOverrides)
- if !ok {
- permalinks = make(PermalinkOverrides)
+ permalinks := make(PermalinkOverrides)
+ for k, v := range viper.GetStringMapString("Permalinks") {
+ permalinks[k] = PathPattern(v)
}
s.Info = SiteInfo{
t.Errorf("Expected FOOBAR_PARAM: got %s", buf.String())
}
}
+
+func TestSiteInfoPermalinks (t *testing.T) {
+ viper.Set("Permalinks", map[string]interface{}{"section": "/:title"})
+ s := &Site{}
+
+ s.initialize()
+ permalink := s.Info.Permalinks["section"]
+
+ if permalink != "/:title" {
+ t.Errorf("Could not set permalink (%#v)", permalink)
+ }
+}