Skip to content

Commit 92cb8f5

Browse files
committed
test: added test cases and ci fix
1 parent 37c3c8b commit 92cb8f5

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

cmd/cmd_test.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -361,15 +361,18 @@ func TestUse_NotInRepo_Errors(t *testing.T) {
361361
func TestUse_InRepo_Success(t *testing.T) {
362362
cfg := tmpCfg(t)
363363
dir := initGitRepo(t)
364-
mustRun(t, cfg, "add", "--id", "work", "--name", "Jane Dev", "--email", "jane@co.com")
364+
// --gpg-key "" resets the pflag variable so GPG settings from earlier tests
365+
// (cobra reuses the command struct and pflag does not reset between Execute calls)
366+
// don't leak into this profile and get applied to a git repo.
367+
mustRun(t, cfg, "add", "--id", "work", "--name", "Jane Dev", "--email", "jane@co.com", "--gpg-key", "")
365368
chdir(t, dir)
366369
mustRun(t, cfg, "use", "work")
367370
}
368371

369372
func TestUse_InRepo_WithSSHKey_Success(t *testing.T) {
370373
cfg := tmpCfg(t)
371374
dir := initGitRepo(t)
372-
mustRun(t, cfg, "add", "--id", "oss", "--name", "Dev", "--email", "dev@oss.org", "--ssh-key", "~/.ssh/id_oss")
375+
mustRun(t, cfg, "add", "--id", "oss", "--name", "Dev", "--email", "dev@oss.org", "--ssh-key", "~/.ssh/id_oss", "--gpg-key", "")
373376
chdir(t, dir)
374377
mustRun(t, cfg, "use", "oss")
375378
}
@@ -397,7 +400,7 @@ func TestSetDefault_NotInRepo_Errors(t *testing.T) {
397400
func TestSetDefault_InRepo_Success(t *testing.T) {
398401
cfg := tmpCfg(t)
399402
dir := initGitRepo(t)
400-
mustRun(t, cfg, "add", "--id", "work", "--name", "Jane", "--email", "jane@co.com")
403+
mustRun(t, cfg, "add", "--id", "work", "--name", "Jane", "--email", "jane@co.com", "--gpg-key", "")
401404
chdir(t, dir)
402405
mustRun(t, cfg, "set-default", "work")
403406
}
@@ -430,7 +433,7 @@ func TestEnsure_NoDefault_NoTTY_Errors(t *testing.T) {
430433
func TestEnsure_WithLocalDefault_InRepo_Success(t *testing.T) {
431434
cfg := tmpCfg(t)
432435
dir := initGitRepo(t)
433-
mustRun(t, cfg, "add", "--id", "work", "--name", "Jane", "--email", "jane@co.com")
436+
mustRun(t, cfg, "add", "--id", "work", "--name", "Jane", "--email", "jane@co.com", "--gpg-key", "")
434437
chdir(t, dir)
435438
mustRun(t, cfg, "set-default", "work")
436439
mustRun(t, cfg, "ensure")

0 commit comments

Comments
 (0)