(t *testing.T)
| 250 | } |
| 251 | |
| 252 | func TestConfigFlags(t *testing.T) { |
| 253 | t.Parallel() |
| 254 | a := assertions.New(t) |
| 255 | |
| 256 | config := InitializeWithDefaults("test", "test", defaults) |
| 257 | a.So(config, should.NotBeNil) |
| 258 | |
| 259 | settings := new(example) |
| 260 | |
| 261 | os.Unsetenv("TEST_BOOL") |
| 262 | os.Unsetenv("TEST_DURATION") |
| 263 | os.Unsetenv("TEST_TIME") |
| 264 | os.Unsetenv("TEST_FLOAT") |
| 265 | os.Unsetenv("TEST_INT") |
| 266 | os.Unsetenv("TEST_STRING") |
| 267 | os.Unsetenv("TEST_STRINGS") |
| 268 | os.Unsetenv("TEST_STRINGPTR") |
| 269 | os.Unsetenv("TEST_BYTES") |
| 270 | os.Unsetenv("TEST_STRINGMAP") |
| 271 | os.Unsetenv("TEST_BUFFERMAP") |
| 272 | os.Unsetenv("TEST_STRINGMAPSLICE") |
| 273 | os.Unsetenv("TEST_NESTED_STRING") |
| 274 | os.Unsetenv("TEST_NESTEDPTR_STRING") |
| 275 | os.Unsetenv("TEST_CUSTOM") |
| 276 | |
| 277 | // parse command line args |
| 278 | err := config.Parse( |
| 279 | "--duration", "10m", |
| 280 | "--time", "2017-08-12 01:02:03 +0000 UTC", |
| 281 | "--float", "12.45", |
| 282 | "--int", "345", |
| 283 | "--string", "bababa", |
| 284 | "--strings", "x", |
| 285 | "--strings", "y", |
| 286 | "--strings", "z", |
| 287 | "--stringptr", "yo", |
| 288 | "--bytes", "99FD", |
| 289 | "--stringmap", "q=r", |
| 290 | "--stringmap", "s=t", |
| 291 | "--buffermap", "a=0x0bcd", |
| 292 | "--buffermap", "c=0x0def", |
| 293 | "--nested.string", "mud", |
| 294 | "--nestedptr.string", "mad", |
| 295 | "--custom", "bar", |
| 296 | "--customs", "bar", |
| 297 | "--customs", "foo", |
| 298 | "--stringmapslice", "a=b", |
| 299 | "--stringmapslice", "a=c", |
| 300 | "--stringmapslice", "d=e", |
| 301 | ) |
| 302 | a.So(err, should.BeNil) |
| 303 | |
| 304 | // unmarshal |
| 305 | err = config.Unmarshal(settings) |
| 306 | a.So(err, should.BeNil) |
| 307 | |
| 308 | str := "yo" |
| 309 | a.So(settings, should.Resemble, &example{ |
nothing calls this directly
no test coverage detected