|
|
@ -6,12 +6,11 @@ package markdown_test |
|
|
|
import ( |
|
|
|
import ( |
|
|
|
"context" |
|
|
|
"context" |
|
|
|
"html/template" |
|
|
|
"html/template" |
|
|
|
"os" |
|
|
|
|
|
|
|
"strings" |
|
|
|
"strings" |
|
|
|
"testing" |
|
|
|
"testing" |
|
|
|
|
|
|
|
|
|
|
|
"code.gitea.io/gitea/models/unittest" |
|
|
|
|
|
|
|
"code.gitea.io/gitea/modules/git" |
|
|
|
"code.gitea.io/gitea/modules/git" |
|
|
|
|
|
|
|
"code.gitea.io/gitea/modules/gitrepo" |
|
|
|
"code.gitea.io/gitea/modules/log" |
|
|
|
"code.gitea.io/gitea/modules/log" |
|
|
|
"code.gitea.io/gitea/modules/markup" |
|
|
|
"code.gitea.io/gitea/modules/markup" |
|
|
|
"code.gitea.io/gitea/modules/markup/markdown" |
|
|
|
"code.gitea.io/gitea/modules/markup/markdown" |
|
|
@ -25,28 +24,36 @@ import ( |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
const ( |
|
|
|
const ( |
|
|
|
AppURL = "http://localhost:3000/" |
|
|
|
AppURL = "http://localhost:3000/" |
|
|
|
FullURL = AppURL + "gogits/gogs/" |
|
|
|
testRepoOwnerName = "user13" |
|
|
|
|
|
|
|
testRepoName = "repo11" |
|
|
|
|
|
|
|
FullURL = AppURL + testRepoOwnerName + "/" + testRepoName + "/" |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
// these values should match the const above
|
|
|
|
// these values should match the const above
|
|
|
|
var localMetas = map[string]string{ |
|
|
|
var localMetas = map[string]string{ |
|
|
|
"user": "gogits", |
|
|
|
"user": testRepoOwnerName, |
|
|
|
"repo": "gogs", |
|
|
|
"repo": testRepoName, |
|
|
|
"repoPath": "../../../tests/gitea-repositories-meta/user13/repo11.git/", |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func TestMain(m *testing.M) { |
|
|
|
type mockRepo struct { |
|
|
|
unittest.InitSettings() |
|
|
|
OwnerName string |
|
|
|
if err := git.InitSimple(context.Background()); err != nil { |
|
|
|
RepoName string |
|
|
|
log.Fatal("git init failed, err: %v", err) |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func (m *mockRepo) GetOwnerName() string { |
|
|
|
|
|
|
|
return m.OwnerName |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func (m *mockRepo) GetName() string { |
|
|
|
|
|
|
|
return m.RepoName |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func newMockRepo(ownerName, repoName string) gitrepo.Repository { |
|
|
|
|
|
|
|
return &mockRepo{ |
|
|
|
|
|
|
|
OwnerName: ownerName, |
|
|
|
|
|
|
|
RepoName: repoName, |
|
|
|
} |
|
|
|
} |
|
|
|
markup.Init(&markup.ProcessorHelper{ |
|
|
|
|
|
|
|
IsUsernameMentionable: func(ctx context.Context, username string) bool { |
|
|
|
|
|
|
|
return username == "r-lyeh" |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
os.Exit(m.Run()) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func TestRender_StandardLinks(t *testing.T) { |
|
|
|
func TestRender_StandardLinks(t *testing.T) { |
|
|
@ -133,11 +140,11 @@ func testAnswers(baseURLContent, baseURLImages string) []string { |
|
|
|
<li><a href="` + baseURLContent + `/Links" rel="nofollow">Links, Language bindings, Engine bindings</a></li> |
|
|
|
<li><a href="` + baseURLContent + `/Links" rel="nofollow">Links, Language bindings, Engine bindings</a></li> |
|
|
|
<li><a href="` + baseURLContent + `/Tips" rel="nofollow">Tips</a></li> |
|
|
|
<li><a href="` + baseURLContent + `/Tips" rel="nofollow">Tips</a></li> |
|
|
|
</ul> |
|
|
|
</ul> |
|
|
|
<p>See commit <a href="/gogits/gogs/commit/65f1bf27bc" rel="nofollow"><code>65f1bf27bc</code></a></p> |
|
|
|
<p>See commit <a href="/` + testRepoOwnerName + `/` + testRepoName + `/commit/65f1bf27bc" rel="nofollow"><code>65f1bf27bc</code></a></p> |
|
|
|
<p>Ideas and codes</p> |
|
|
|
<p>Ideas and codes</p> |
|
|
|
<ul> |
|
|
|
<ul> |
|
|
|
<li>Bezier widget (by <a href="/r-lyeh" rel="nofollow">@r-lyeh</a>) <a href="http://localhost:3000/ocornut/imgui/issues/786" class="ref-issue" rel="nofollow">ocornut/imgui#786</a></li> |
|
|
|
<li>Bezier widget (by <a href="/r-lyeh" rel="nofollow">@r-lyeh</a>) <a href="http://localhost:3000/ocornut/imgui/issues/786" class="ref-issue" rel="nofollow">ocornut/imgui#786</a></li> |
|
|
|
<li>Bezier widget (by <a href="/r-lyeh" rel="nofollow">@r-lyeh</a>) <a href="http://localhost:3000/gogits/gogs/issues/786" class="ref-issue" rel="nofollow">#786</a></li> |
|
|
|
<li>Bezier widget (by <a href="/r-lyeh" rel="nofollow">@r-lyeh</a>) <a href="` + FullURL + `issues/786" class="ref-issue" rel="nofollow">#786</a></li> |
|
|
|
<li>Node graph editors <a href="https://github.com/ocornut/imgui/issues/306" rel="nofollow">https://github.com/ocornut/imgui/issues/306</a></li>
|
|
|
|
<li>Node graph editors <a href="https://github.com/ocornut/imgui/issues/306" rel="nofollow">https://github.com/ocornut/imgui/issues/306</a></li>
|
|
|
|
<li><a href="` + baseURLContent + `/memory_editor_example" rel="nofollow">Memory Editor</a></li> |
|
|
|
<li><a href="` + baseURLContent + `/memory_editor_example" rel="nofollow">Memory Editor</a></li> |
|
|
|
<li><a href="` + baseURLContent + `/plot_var_example" rel="nofollow">Plot var helper</a></li> |
|
|
|
<li><a href="` + baseURLContent + `/plot_var_example" rel="nofollow">Plot var helper</a></li> |
|
|
@ -222,7 +229,7 @@ See commit 65f1bf27bc |
|
|
|
Ideas and codes |
|
|
|
Ideas and codes |
|
|
|
|
|
|
|
|
|
|
|
- Bezier widget (by @r-lyeh) ` + AppURL + `ocornut/imgui/issues/786 |
|
|
|
- Bezier widget (by @r-lyeh) ` + AppURL + `ocornut/imgui/issues/786 |
|
|
|
- Bezier widget (by @r-lyeh) ` + AppURL + `gogits/gogs/issues/786 |
|
|
|
- Bezier widget (by @r-lyeh) ` + FullURL + `issues/786 |
|
|
|
- Node graph editors https://github.com/ocornut/imgui/issues/306
|
|
|
|
- Node graph editors https://github.com/ocornut/imgui/issues/306
|
|
|
|
- [[Memory Editor|memory_editor_example]] |
|
|
|
- [[Memory Editor|memory_editor_example]] |
|
|
|
- [[Plot var helper|plot_var_example]]`, |
|
|
|
- [[Plot var helper|plot_var_example]]`, |
|
|
@ -299,6 +306,7 @@ func TestTotal_RenderWiki(t *testing.T) { |
|
|
|
Links: markup.Links{ |
|
|
|
Links: markup.Links{ |
|
|
|
Base: FullURL, |
|
|
|
Base: FullURL, |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
Repo: newMockRepo(testRepoOwnerName, testRepoName), |
|
|
|
Metas: localMetas, |
|
|
|
Metas: localMetas, |
|
|
|
IsWiki: true, |
|
|
|
IsWiki: true, |
|
|
|
}, sameCases[i]) |
|
|
|
}, sameCases[i]) |
|
|
@ -344,6 +352,7 @@ func TestTotal_RenderString(t *testing.T) { |
|
|
|
Base: FullURL, |
|
|
|
Base: FullURL, |
|
|
|
BranchPath: "master", |
|
|
|
BranchPath: "master", |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
Repo: newMockRepo(testRepoOwnerName, testRepoName), |
|
|
|
Metas: localMetas, |
|
|
|
Metas: localMetas, |
|
|
|
}, sameCases[i]) |
|
|
|
}, sameCases[i]) |
|
|
|
assert.NoError(t, err) |
|
|
|
assert.NoError(t, err) |
|
|
|