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

Function TestRepository_ComposeMetas

internal/database/repo_test.go:16–59  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

14)
15
16func TestRepository_ComposeMetas(t *testing.T) {
17 repo := &Repository{
18 Name: "testrepo",
19 Owner: &User{
20 Name: "testuser",
21 },
22 ExternalTrackerFormat: "https://someurl.com/{user}/{repo}/{issue}",
23 }
24
25 t.Run("no external tracker is configured", func(t *testing.T) {
26 repo.EnableExternalTracker = false
27
28 metas := repo.ComposeMetas()
29 assert.Equal(t, metas["repoLink"], repo.Link())
30
31 // Should not have format and style if no external tracker is configured
32 _, ok := metas["format"]
33 assert.False(t, ok)
34 _, ok = metas["style"]
35 assert.False(t, ok)
36 })
37
38 t.Run("an external issue tracker is configured", func(t *testing.T) {
39 repo.ExternalMetas = nil
40 repo.EnableExternalTracker = true
41
42 // Default to numeric issue style
43 assert.Equal(t, markup.IssueNameStyleNumeric, repo.ComposeMetas()["style"])
44 repo.ExternalMetas = nil
45
46 repo.ExternalTrackerStyle = markup.IssueNameStyleNumeric
47 assert.Equal(t, markup.IssueNameStyleNumeric, repo.ComposeMetas()["style"])
48 repo.ExternalMetas = nil
49
50 repo.ExternalTrackerStyle = markup.IssueNameStyleAlphanumeric
51 assert.Equal(t, markup.IssueNameStyleAlphanumeric, repo.ComposeMetas()["style"])
52 repo.ExternalMetas = nil
53
54 metas := repo.ComposeMetas()
55 assert.Equal(t, "testuser", metas["user"])
56 assert.Equal(t, "testrepo", metas["repo"])
57 assert.Equal(t, "https://someurl.com/{user}/{repo}/{issue}", metas["format"])
58 })
59}
60
61func Test_CreateRepository_PreventDeletion(t *testing.T) {
62 tempRepositoryRoot := filepath.Join(os.TempDir(), "createRepository-tempRepositoryRoot")

Callers

nothing calls this directly

Calls 2

ComposeMetasMethod · 0.95
LinkMethod · 0.95

Tested by

no test coverage detected