mirror of
https://github.com/dolthub/dolt.git
synced 2026-02-08 02:59:37 -06:00
Fixed bug in init and fixed tests
This commit is contained in:
@@ -91,14 +91,17 @@ func (cmd InitCmd) Exec(ctx context.Context, commandStr string, args []string, d
|
||||
return 1
|
||||
}
|
||||
|
||||
// This command creates a commit, so we need user identity
|
||||
if !cli.CheckUserNameAndEmail(dEnv) {
|
||||
return 1
|
||||
}
|
||||
|
||||
name, _ := apr.GetValue(usernameParamName)
|
||||
email, _ := apr.GetValue(emailParamName)
|
||||
initBranch, _ := apr.GetValue(initBranchParamName)
|
||||
|
||||
if len(name) == 0 || len(email) == 0 {
|
||||
// This command creates a commit, so we need user identity
|
||||
if !cli.CheckUserNameAndEmail(dEnv) {
|
||||
return 1
|
||||
}
|
||||
}
|
||||
|
||||
name = dEnv.Config.IfEmptyUseConfig(name, env.UserNameKey)
|
||||
email = dEnv.Config.IfEmptyUseConfig(email, env.UserEmailKey)
|
||||
if initBranch == "" {
|
||||
|
||||
@@ -58,25 +58,27 @@ func TestInit(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
dEnv := createUninitializedEnv()
|
||||
gCfg, _ := dEnv.Config.GetConfig(env.GlobalConfig)
|
||||
gCfg.SetStrings(test.GlobalConfig)
|
||||
t.Run(test.Name, func(t *testing.T) {
|
||||
dEnv := createUninitializedEnv()
|
||||
gCfg, _ := dEnv.Config.GetConfig(env.GlobalConfig)
|
||||
gCfg.SetStrings(test.GlobalConfig)
|
||||
|
||||
result := InitCmd{}.Exec(context.Background(), "dolt init", test.Args, dEnv)
|
||||
result := InitCmd{}.Exec(context.Background(), "dolt init", test.Args, dEnv)
|
||||
|
||||
if (result == 0) != test.ExpectSuccess {
|
||||
t.Error(test.Name, "- Expected success:", test.ExpectSuccess, "result:", result == 0)
|
||||
} else if test.ExpectSuccess {
|
||||
// succceeded as expected
|
||||
if !dEnv.HasDoltDir() {
|
||||
t.Error(test.Name, "- .dolt dir should exist after initialization")
|
||||
if (result == 0) != test.ExpectSuccess {
|
||||
t.Error(test.Name, "- Expected success:", test.ExpectSuccess, "result:", result == 0)
|
||||
} else if test.ExpectSuccess {
|
||||
// succceeded as expected
|
||||
if !dEnv.HasDoltDir() {
|
||||
t.Error(test.Name, "- .dolt dir should exist after initialization")
|
||||
}
|
||||
} else {
|
||||
// failed as expected
|
||||
if dEnv.HasDoltDir() {
|
||||
t.Error(test.Name, "- dolt directory shouldn't exist after failure to initialize")
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// failed as expected
|
||||
if dEnv.HasDoltDir() {
|
||||
t.Error(test.Name, "- dolt directory shouldn't exist after failure to initialize")
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user