MCPcopy
hub / github.com/cli/cli / Test_helperRun

Function Test_helperRun

pkg/cmd/auth/gitcredential/helper_test.go:21–257  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

19}
20
21func Test_helperRun(t *testing.T) {
22 tests := []struct {
23 name string
24 opts CredentialOptions
25 input string
26 wantStdout string
27 wantStderr string
28 wantErr bool
29 }{
30 {
31 name: "host only, credentials found",
32 opts: CredentialOptions{
33 Operation: "get",
34 Config: func() (config, error) {
35 return tinyConfig{
36 "_source": "/Users/monalisa/.config/gh/hosts.yml",
37 "example.com:user": "monalisa",
38 "example.com:oauth_token": "OTOKEN",
39 }, nil
40 },
41 },
42 input: heredoc.Doc(`
43 protocol=https
44 host=example.com
45 `),
46 wantErr: false,
47 wantStdout: heredoc.Doc(`
48 protocol=https
49 host=example.com
50 username=monalisa
51 password=OTOKEN
52 `),
53 wantStderr: "",
54 },
55 {
56 name: "host plus user",
57 opts: CredentialOptions{
58 Operation: "get",
59 Config: func() (config, error) {
60 return tinyConfig{
61 "_source": "/Users/monalisa/.config/gh/hosts.yml",
62 "example.com:user": "monalisa",
63 "example.com:oauth_token": "OTOKEN",
64 }, nil
65 },
66 },
67 input: heredoc.Doc(`
68 protocol=https
69 host=example.com
70 username=monalisa
71 `),
72 wantErr: false,
73 wantStdout: heredoc.Doc(`
74 protocol=https
75 host=example.com
76 username=monalisa
77 password=OTOKEN
78 `),

Callers

nothing calls this directly

Calls 5

TestFunction · 0.92
helperRunFunction · 0.85
RunMethod · 0.65
ErrorfMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected