MCPcopy
hub / github.com/cli/cli / Test_NewCmdLogin

Function Test_NewCmdLogin

pkg/cmd/auth/login/login_test.go:36–299  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

34}
35
36func Test_NewCmdLogin(t *testing.T) {
37 tests := []struct {
38 name string
39 cli string
40 stdin string
41 stdinTTY bool
42 defaultHost string
43 wants LoginOptions
44 wantsErr bool
45 }{
46 {
47 name: "nontty, with-token",
48 stdin: "abc123\n",
49 cli: "--with-token",
50 wants: LoginOptions{
51 Hostname: "github.com",
52 Token: "abc123",
53 },
54 },
55 {
56 name: "nontty, with-token, enterprise default host",
57 stdin: "abc123\n",
58 cli: "--with-token",
59 defaultHost: "git.example.com",
60 wants: LoginOptions{
61 Hostname: "git.example.com",
62 Token: "abc123",
63 },
64 },
65 {
66 name: "tty, with-token",
67 stdinTTY: true,
68 stdin: "def456",
69 cli: "--with-token",
70 wants: LoginOptions{
71 Hostname: "github.com",
72 Token: "def456",
73 },
74 },
75 {
76 name: "nontty, hostname",
77 stdinTTY: false,
78 cli: "--hostname claire.redfield",
79 wants: LoginOptions{
80 Hostname: "claire.redfield",
81 Token: "",
82 },
83 },
84 {
85 name: "nontty",
86 stdinTTY: false,
87 cli: "",
88 wants: LoginOptions{
89 Hostname: "github.com",
90 Token: "",
91 },
92 },
93 {

Callers

nothing calls this directly

Calls 7

TestFunction · 0.92
NewCmdLoginFunction · 0.85
SetStdoutTTYMethod · 0.80
SetStdinTTYMethod · 0.80
EqualMethod · 0.80
RunMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected