func TestLoadInitConfigAllDefaultSomeFlagErrorParser(t *testing.T) {
	// INIT
	config := newConfiguration()
	defaultPointers := newDefaultPointersConfiguration()

	args := []string{
		"--loglevel=INFO",
		"--db",
		"--owner.name",
		"--owner.dob=2016-04-20T17:39:00Z",
	}

	// catch stdout
	rescueStdout := os.Stdout
	_, w, _ := os.Pipe()
	os.Stdout = w

	// TEST
	err := Load(config, defaultPointers, args)
	if err != ErrParserNotFound {
		t.Errorf("Expexted error %s\ngot %s", ErrParserNotFound, err)
	}

	// read and restore stdout
	err = w.Close()
	if err != nil {
		t.Fatal(err)
	}

	os.Stdout = rescueStdout

	// check continue on error
	check := newConfiguration()
	check.LogLevel = "INFO"
	check.Db = newDefaultPointersConfiguration().Db
	check.Owner.Name = newDefaultPointersConfiguration().Owner.Name
	check.Owner.DateOfBirth, _ = time.Parse(time.RFC3339, "2016-04-20T17:39:00Z")

	if !reflect.DeepEqual(config, check) {
		if !reflect.DeepEqual(config.Owner, check.Owner) {
			t.Errorf("\nexpected\t: %+v\ngot\t\t\t: %+v", check.Owner, config.Owner)
		}
		t.Errorf("Error :\nexpected \t%+v \ngot \t\t%+v\n", check, config)
	}
}
// Test Load without parsers on not empty config with all default values on pointers and with some flags called
Test Load without parsers on not empty config with all default values on pointers and with some flags called
// Test Load without parsers on not empty config with all default values on pointers and with some flags called
func TestLoadInitConfigAllDefaultSomeFlagErrorParser(t *testing.T) {
	config := newConfiguration()
	defaultPointers := newDefaultPointersConfiguration()
	args := []string{
		"--loglevel=INFO",
		"--db",
		"--owner.name",
		"--owner.dob=2016-04-20T17:39:00Z",
	}
	rescueStdout := os.Stdout
	_, w, _ := os.Pipe()
	os.Stdout = w
	err := Load(config, defaultPointers, args)
	if err != ErrParserNotFound {
		t.Errorf("Expexted error %s\ngot %s", ErrParserNotFound, err)
	}
	err = w.Close()
	if err != nil {
		t.Fatal(err)
	}
	os.Stdout = rescueStdout
	check := newConfiguration()
	check.LogLevel = "INFO"
	check.Db = newDefaultPointersConfiguration().Db
	check.Owner.Name = newDefaultPointersConfiguration().Owner.Name
	check.Owner.DateOfBirth, _ = time.Parse(time.RFC3339, "2016-04-20T17:39:00Z")
	if !reflect.DeepEqual(config, check) {
		if !reflect.DeepEqual(config.Owner, check.Owner) {
			t.Errorf("\nexpected\t: %+v\ngot\t\t\t: %+v", check.Owner, config.Owner)
		}
		t.Errorf("Error :\nexpected \t%+v \ngot \t\t%+v\n", check, config)
	}
}
func TestLoadInitConfigAllDefaultSomeFlagErrorParser ( t * testing . T ) { config := newConfiguration ( ) defaultPointers := newDefaultPointersConfiguration ( ) args := [ ] string { " " , " " , " " , " " , } rescueStdout := os . Stdout _ , w , _ := os . Pipe ( ) os . Stdout = w err := Load ( config , defaultPointers , args ) if err != ErrParserNotFound { t . Errorf ( " \n " , ErrParserNotFound , err ) } err = w . Close ( ) if err != nil { t . Fatal ( err ) } os . Stdout = rescueStdout check := newConfiguration ( ) check . LogLevel = " " check . Db = newDefaultPointersConfiguration ( ) . Db check . Owner . Name = newDefaultPointersConfiguration ( ) . Owner . Name check . Owner . DateOfBirth , _ = time . Parse ( time . RFC3339 , " " ) if ! reflect . DeepEqual ( config , check ) { if ! reflect . DeepEqual ( config . Owner , check . Owner ) { t . Errorf ( " \n \t \n \t \t \t " , check . Owner , config . Owner ) } t . Errorf ( " \n \t \n \t \t \n " , check , config ) } }
Test Load without parsers on not empty config with all default values on pointers and with some flags called
Test Load without parsers on not empty config with all default values on pointers and with some flags called
// INIT // catch stdout // TEST // read and restore stdout // check continue on error