package remote import ( "os" "testing" ) func TestNewConfig(t *testing.T) { osArgsWas := os.Args[:] defer func() { os.Args = osArgsWas[:] }() os.Args = []string{"ignore", "-remote", "remotename", "-p", "password", "other"} if conf, err := NewConfig(); err != nil { t.Errorf("new config failed: %v", err) } else if conf.remote != "remotename" { t.Errorf("new config no remote flag: %v", conf.remote) } else if conf.password != "password" { t.Errorf("new config no password flag: %v", conf.password) } else if conf.args[0] != "other" { t.Errorf("new config no other args: %v", conf.args) } }