MCPcopy Create free account
hub / github.com/gogs/gogs / TestRenderSha1CurrentPattern

Function TestRenderSha1CurrentPattern

internal/markup/markup_test.go:229–265  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

227}
228
229func TestRenderSha1CurrentPattern(t *testing.T) {
230 metas := map[string]string{
231 "repoLink": "/someuser/somerepo",
232 }
233
234 tests := []struct {
235 desc string
236 input string
237 prefix string
238 expVal string
239 }{
240 {
241 desc: "Full SHA (40 symbols)",
242 input: "ad8ced4f57d9068cb2874557245be3c7f341149d",
243 prefix: metas["repoLink"],
244 expVal: `<a href="/someuser/somerepo/commit/ad8ced4f57d9068cb2874557245be3c7f341149d"><code>ad8ced4f57</code></a>`,
245 },
246 {
247 desc: "Short SHA (8 symbols)",
248 input: "ad8ced4f",
249 prefix: metas["repoLink"],
250 expVal: `<a href="/someuser/somerepo/commit/ad8ced4f"><code>ad8ced4f</code></a>`,
251 },
252 {
253 desc: "9 digits",
254 input: "123456789",
255 prefix: metas["repoLink"],
256 expVal: "123456789",
257 },
258 }
259
260 for _, test := range tests {
261 t.Run(test.desc, func(t *testing.T) {
262 assert.Equal(t, test.expVal, string(RenderSha1CurrentPattern([]byte(test.input), test.prefix)))
263 })
264 }
265}

Callers

nothing calls this directly

Calls 2

stringFunction · 0.85
RenderSha1CurrentPatternFunction · 0.85

Tested by

no test coverage detected