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

Function TestViewRun

pkg/cmd/repo/gitignore/view/view_test.go:18–123  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

16)
17
18func TestViewRun(t *testing.T) {
19 tests := []struct {
20 name string
21 opts *ViewOptions
22 isTTY bool
23 httpStubs func(t *testing.T, reg *httpmock.Registry)
24 wantStdout string
25 wantStderr string
26 wantErr bool
27 errMsg string
28 }{
29 {
30 name: "No template",
31 opts: &ViewOptions{},
32 wantErr: true,
33 errMsg: "no template provided",
34 },
35 {
36 name: "happy path with template",
37 opts: &ViewOptions{Template: "Go"},
38 wantErr: false,
39 httpStubs: func(t *testing.T, reg *httpmock.Registry) {
40 reg.Register(
41 httpmock.REST("GET", "gitignore/templates/Go"),
42 httpmock.StringResponse(`{
43 "name": "Go",
44 "source": "# If you prefer the allow list template instead of the deny list, see community template:\n# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore\n#\n# Binaries for programs and plugins\n*.exe\n*.exe~\n*.dll\n*.so\n*.dylib\n\n# Test binary, built with go test -c\n*.test\n\n# Output of the go coverage tool, specifically when used with LiteIDE\n*.out\n\n# Dependency directories (remove the comment below to include it)\n# vendor/\n\n# Go workspace file\ngo.work\ngo.work.sum\n\n# env file\n.env\n"
45 }`,
46 ))
47 },
48 wantStdout: heredoc.Doc(`# If you prefer the allow list template instead of the deny list, see community template:
49 # https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore
50 #
51 # Binaries for programs and plugins
52 *.exe
53 *.exe~
54 *.dll
55 *.so
56 *.dylib
57
58 # Test binary, built with go test -c
59 *.test
60
61 # Output of the go coverage tool, specifically when used with LiteIDE
62 *.out
63
64 # Dependency directories (remove the comment below to include it)
65 # vendor/
66
67 # Go workspace file
68 go.work
69 go.work.sum
70
71 # env file
72 .env
73 `),
74 },
75 {

Callers

nothing calls this directly

Calls 15

RegisterMethod · 0.95
VerifyMethod · 0.95
RESTFunction · 0.92
StringResponseFunction · 0.92
StatusStringResponseFunction · 0.92
NewMockConfigFunction · 0.92
TestFunction · 0.92
SetStdoutTTYMethod · 0.80
SetStdinTTYMethod · 0.80
SetStderrTTYMethod · 0.80
EqualMethod · 0.80
viewRunFunction · 0.70

Tested by

no test coverage detected