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

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

	// init command
	rootCmd := &Command{
		Name: "flaegtest",
		Description: `flaegtest is a test program made to test flaeg library.
Complete documentation is available at https://github.com/containous/flaeg`,
		Config:                config,
		DefaultPointersConfig: defaultPointers,
		Run: func() error {
			//CHECK
			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) {
				msg := fmt.Sprintf("\nexpected \t%+v \ngot \t\t%+v\n", check, config)
				return errors.New(msg)
			}
			return nil
		},
	}

	// TEST
	// init flaeg
	flaeg := New(rootCmd, args)
	// add custom parser to flaeg
	flaeg.AddParser(reflect.TypeOf([]ServerInfo{}), &sliceServerValue{})

	// run test
	if err := flaeg.Run(); err != nil {
		t.Fatal(err)
	}
}
// Test Commands feature with only the root command
Test Commands feature with only the root command
// Test Commands feature with only the root command
func TestFlaegCommandRootInitConfigAllDefaultSomeFlag(t *testing.T) {
	config := newConfiguration()
	defaultPointers := newDefaultPointersConfiguration()
	args := []string{
		"--loglevel=INFO",
		"--db",
		"--owner.name",
		"--owner.dob=2016-04-20T17:39:00Z",
	}
	rootCmd := &Command{
		Name: "flaegtest",
		Description: `flaegtest is a test program made to test flaeg library.
Complete documentation is available at https://github.com/containous/flaeg`,
		Config:                config,
		DefaultPointersConfig: defaultPointers,
		Run: func() 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) {
				msg := fmt.Sprintf("\nexpected \t%+v \ngot \t\t%+v\n", check, config)
				return errors.New(msg)
			}
			return nil
		},
	}
	flaeg := New(rootCmd, args)
	flaeg.AddParser(reflect.TypeOf([]ServerInfo{}), &sliceServerValue{})
	if err := flaeg.Run(); err != nil {
		t.Fatal(err)
	}
}
func TestFlaegCommandRootInitConfigAllDefaultSomeFlag ( t * testing . T ) { config := newConfiguration ( ) defaultPointers := newDefaultPointersConfiguration ( ) args := [ ] string { " " , " " , " " , " " , } rootCmd := & Command { Name : " " , Description : `flaegtest is a test program made to test flaeg library.
Complete documentation is available at https://github.com/containous/flaeg` , Config : config , DefaultPointersConfig : defaultPointers , Run : func ( ) error { 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 ) { msg := fmt . Sprintf ( " \n \t \n \t \t \n " , check , config ) return errors . New ( msg ) } return nil } , } flaeg := New ( rootCmd , args ) flaeg . AddParser ( reflect . TypeOf ( [ ] ServerInfo { } ) , & sliceServerValue { } ) if err := flaeg . Run ( ) ; err != nil { t . Fatal ( err ) } }
Test Commands feature with only the root command
Test Commands feature with only the root command
// INIT // init command //CHECK // TEST // init flaeg // add custom parser to flaeg // run test