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

Function TestLicenseTemplateReturnsLicense

api/queries_repo_test.go:1135–1207  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1133}
1134
1135func TestLicenseTemplateReturnsLicense(t *testing.T) {
1136 licenseTemplateName := "mit"
1137 hostname := "api.github.com"
1138 httpStubs := func(reg *httpmock.Registry) {
1139 reg.Register(
1140 httpmock.REST("GET", fmt.Sprintf("licenses/%v", licenseTemplateName)),
1141 httpmock.StringResponse(`{
1142 "key": "mit",
1143 "name": "MIT License",
1144 "spdx_id": "MIT",
1145 "url": "https://api.github.com/licenses/mit",
1146 "node_id": "MDc6TGljZW5zZTEz",
1147 "html_url": "http://choosealicense.com/licenses/mit/",
1148 "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.",
1149 "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.",
1150 "permissions": [
1151 "commercial-use",
1152 "modifications",
1153 "distribution",
1154 "private-use"
1155 ],
1156 "conditions": [
1157 "include-copyright"
1158 ],
1159 "limitations": [
1160 "liability",
1161 "warranty"
1162 ],
1163 "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",
1164 "featured": true
1165 }`,
1166 ))
1167 }
1168 wantLicense := &License{
1169 Key: "mit",
1170 Name: "MIT License",
1171 SPDXID: "MIT",
1172 URL: "https://api.github.com/licenses/mit",
1173 NodeID: "MDc6TGljZW5zZTEz",
1174 HTMLURL: "http://choosealicense.com/licenses/mit/",
1175 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.",
1176 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.",
1177 Permissions: []string{
1178 "commercial-use",
1179 "modifications",
1180 "distribution",
1181 "private-use",
1182 },
1183 Conditions: []string{
1184 "include-copyright",
1185 },
1186 Limitations: []string{
1187 "liability",
1188 "warranty",
1189 },
1190 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",
1191 Featured: true,
1192 }

Callers

nothing calls this directly

Calls 7

RegisterMethod · 0.95
VerifyMethod · 0.95
RESTFunction · 0.92
StringResponseFunction · 0.92
httpClientInterface · 0.85
RepoLicenseFunction · 0.85
EqualMethod · 0.80

Tested by

no test coverage detected