MCPcopy Index your code
hub / github.com/cli/cli / TestViewRun

Function TestViewRun

pkg/cmd/repo/license/view/view_test.go:82–312  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

80}
81
82func TestViewRun(t *testing.T) {
83 tests := []struct {
84 name string
85 opts *ViewOptions
86 isTTY bool
87 httpStubs func(reg *httpmock.Registry)
88 wantStdout string
89 wantStderr string
90 wantErr bool
91 errMsg string
92 wantBrowsedURL string
93 }{
94 {
95 name: "happy path with license no tty",
96 opts: &ViewOptions{License: "mit"},
97 wantErr: false,
98 isTTY: false,
99 httpStubs: func(reg *httpmock.Registry) {
100 reg.Register(
101 httpmock.REST("GET", "licenses/mit"),
102 httpmock.StringResponse(`{
103 "key": "mit",
104 "name": "MIT License",
105 "spdx_id": "MIT",
106 "url": "https://api.github.com/licenses/mit",
107 "node_id": "MDc6TGljZW5zZTEz",
108 "html_url": "http://choosealicense.com/licenses/mit/",
109 "description": "A short and simple permissive license with conditions only requiring preservation of copyright and license notices. Licensed works, modifications, and larger works may be distributed under different terms and without source code.",
110 "implementation": "Create a text file (typically named LICENSE or LICENSE.txt) in the root of your source code and copy the text of the license into the file. Replace [year] with the current year and [fullname] with the name (or names) of the copyright holders.",
111 "permissions": [
112 "commercial-use",
113 "modifications",
114 "distribution",
115 "private-use"
116 ],
117 "conditions": [
118 "include-copyright"
119 ],
120 "limitations": [
121 "liability",
122 "warranty"
123 ],
124 "body": "MIT License\n\nCopyright (c) [year] [fullname]\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n",
125 "featured": true
126 }`))
127 },
128 wantStdout: heredoc.Doc(`
129 MIT License
130
131 Copyright (c) [year] [fullname]
132
133 Permission is hereby granted, free of charge, to any person obtaining a copy
134 of this software and associated documentation files (the "Software"), to deal
135 in the Software without restriction, including without limitation the rights
136 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
137 copies of the Software, and to permit persons to whom the Software is
138 furnished to do so, subject to the following conditions:
139

Callers

nothing calls this directly

Calls 15

RegisterMethod · 0.95
VerifyMethod · 0.95
BrowsedURLMethod · 0.95
RESTFunction · 0.92
StringResponseFunction · 0.92
StatusStringResponseFunction · 0.92
NewBlankConfigFunction · 0.92
TestFunction · 0.92
SetStdoutTTYMethod · 0.80
SetStdinTTYMethod · 0.80
SetStderrTTYMethod · 0.80
EqualMethod · 0.80

Tested by

no test coverage detected