MCPcopy Create free account
hub / github.com/cli/cli / Test_listRun

Function Test_listRun

pkg/cmd/config/list/list_test.go:73–130  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

71}
72
73func Test_listRun(t *testing.T) {
74 tests := []struct {
75 name string
76 input *ListOptions
77 config gh.Config
78 stdout string
79 wantErr bool
80 }{
81 {
82 name: "list",
83 config: func() gh.Config {
84 cfg := config.NewMockConfig()
85 cfg.Set("HOST", "api_host", "api-gateway.example.com")
86 cfg.Set("HOST", "git_protocol", "ssh")
87 cfg.Set("HOST", "editor", "/usr/bin/vim")
88 cfg.Set("HOST", "prompt", "disabled")
89 cfg.Set("HOST", "prefer_editor_prompt", "enabled")
90 cfg.Set("HOST", "pager", "less")
91 cfg.Set("HOST", "http_unix_socket", "")
92 cfg.Set("HOST", "browser", "brave")
93 cfg.Set("", "clipboard", "enabled")
94 return cfg
95 }(),
96 input: &ListOptions{Hostname: "HOST"},
97 stdout: heredoc.Doc(`
98 api_host=api-gateway.example.com
99 git_protocol=ssh
100 editor=/usr/bin/vim
101 prompt=disabled
102 prefer_editor_prompt=enabled
103 expiring_credentials=disabled
104 pager=less
105 http_unix_socket=
106 browser=brave
107 clipboard=enabled
108 color_labels=disabled
109 accessible_colors=disabled
110 accessible_prompter=disabled
111 spinner=enabled
112 telemetry=enabled
113 `),
114 },
115 }
116
117 for _, tt := range tests {
118 ios, _, stdout, _ := iostreams.Test()
119 tt.input.IO = ios
120 tt.input.Config = func() (gh.Config, error) {
121 return tt.config, nil
122 }
123
124 t.Run(tt.name, func(t *testing.T) {
125 err := listRun(tt.input)
126 require.NoError(t, err)
127 require.Equal(t, tt.stdout, stdout.String())
128 })
129 }
130}

Callers

nothing calls this directly

Calls 7

NewMockConfigFunction · 0.92
TestFunction · 0.92
EqualMethod · 0.80
listRunFunction · 0.70
SetMethod · 0.65
RunMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected