(t *testing.T)
| 2164 | } |
| 2165 | |
| 2166 | func TestUnmarshalingWithAliases(t *testing.T) { |
| 2167 | v := New() |
| 2168 | v.SetDefault("ID", 1) |
| 2169 | v.Set("name", "Steve") |
| 2170 | v.Set("lastname", "Owen") |
| 2171 | |
| 2172 | v.RegisterAlias("UserID", "ID") |
| 2173 | v.RegisterAlias("Firstname", "name") |
| 2174 | v.RegisterAlias("Surname", "lastname") |
| 2175 | |
| 2176 | type config struct { |
| 2177 | ID int |
| 2178 | FirstName string |
| 2179 | Surname string |
| 2180 | } |
| 2181 | |
| 2182 | var C config |
| 2183 | err := v.Unmarshal(&C) |
| 2184 | require.NoError(t, err, "unable to decode into struct") |
| 2185 | |
| 2186 | assert.Equal(t, &config{ID: 1, FirstName: "Steve", Surname: "Owen"}, &C) |
| 2187 | } |
| 2188 | |
| 2189 | func TestSetConfigNameClearsFileCache(t *testing.T) { |
| 2190 | v := New() |
nothing calls this directly
no test coverage detected