mirror of
https://gitea.com/gitea/tea.git
synced 2026-06-06 03:08:44 +02:00
8e0666ab85
Reviewed-on: https://gitea.com/gitea/tea/pulls/1003 Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: techknowlogick <techknowlogick@gitea.com> Co-committed-by: techknowlogick <techknowlogick@gitea.com>
53 lines
1.0 KiB
Go
53 lines
1.0 KiB
Go
// Copyright 2026 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package context
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"gitea.dev/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)
|
|
}
|
|
})
|
|
}
|
|
}
|