mirror of
https://gitea.com/gitea/tea.git
synced 2026-02-22 14:23:30 +01:00
Fix new tty prompt (#897)
Fix #827 --------- Co-authored-by: silverwind <silverwind@noreply.gitea.com> Reviewed-on: https://gitea.com/gitea/tea/pulls/897 Reviewed-by: silverwind <silverwind@noreply.gitea.com>
This commit is contained in:
52
modules/context/context_prompt_test.go
Normal file
52
modules/context/context_prompt_test.go
Normal file
@@ -0,0 +1,52 @@
|
||||
// Copyright 2026 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package context
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"code.gitea.io/tea/modules/config"
|
||||
)
|
||||
|
||||
func TestShouldPromptFallbackLogin(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
login *config.Login
|
||||
canPrompt bool
|
||||
expected bool
|
||||
}{
|
||||
{
|
||||
name: "no login",
|
||||
login: nil,
|
||||
canPrompt: true,
|
||||
expected: false,
|
||||
},
|
||||
{
|
||||
name: "default login",
|
||||
login: &config.Login{Default: true},
|
||||
canPrompt: true,
|
||||
expected: false,
|
||||
},
|
||||
{
|
||||
name: "non-default no prompt",
|
||||
login: &config.Login{Default: false},
|
||||
canPrompt: false,
|
||||
expected: false,
|
||||
},
|
||||
{
|
||||
name: "non-default prompt",
|
||||
login: &config.Login{Default: false},
|
||||
canPrompt: true,
|
||||
expected: true,
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
if got := shouldPromptFallbackLogin(test.login, test.canPrompt); got != test.expected {
|
||||
t.Fatalf("expected %v, got %v", test.expected, got)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user