mirror of
https://gitea.com/gitea/tea.git
synced 2026-10-26 19:11:25 +01:00
fix(repo): README lookup like Gitea, clearer branch/org errors, clone-after-create report, mirror interval 0 and search sort (follow gh)
Signed-off-by: bircni <bircni@icloud.com>
This commit is contained in:
16 files changed
+211
-37
No files matched your search
@@ -79,3 +79,42 @@ func TestRepositoryAssigneesTagsAndMissingPermissions(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, RepositoryPermissions{}, permissions)
|
||||
}
|
||||
|
||||
func TestRepositoryCreateReportsMissingOrganization(t *testing.T) {
|
||||
client := newTestClient(t, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
w.WriteHeader(http.StatusNotFound)
|
||||
_, _ = w.Write([]byte(`{"message":"GetOrgByName"}`))
|
||||
}))
|
||||
_, err := (Repositories{Client: client}).Create(context.Background(), "acme-typo", RepositoryOptions{Name: "tool"})
|
||||
require.EqualError(t, err, `organization "acme-typo" not found`)
|
||||
}
|
||||
|
||||
func TestRepositoryReadme(t *testing.T) {
|
||||
dirEntry := func(name string) string { return `{"name":"` + name + `","path":"` + name + `","type":"dir"}` }
|
||||
fileEntry := func(dir, name string) string {
|
||||
return `{"name":"` + name + `","path":"` + dir + name + `","type":"file"}`
|
||||
}
|
||||
listings := map[string]string{
|
||||
"/api/v1/repos/alice/project/contents/": "[" + fileEntry("", "README.rst") + "," + fileEntry("", "readme.txt") + "," + dirEntry(".github") + "]",
|
||||
"/api/v1/repos/alice/project/contents/.github": "[" + fileEntry(".github/", "README.md") + "]",
|
||||
}
|
||||
client := newTestClient(t, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
if r.URL.Query().Get("ref") == "develp" {
|
||||
w.WriteHeader(http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
if body, ok := listings[r.URL.Path]; ok {
|
||||
_, _ = w.Write([]byte(body))
|
||||
return
|
||||
}
|
||||
assert.Equal(t, "/api/v1/repos/alice/project/raw/.github/README.md", r.URL.Path)
|
||||
_, _ = w.Write([]byte("hello"))
|
||||
}))
|
||||
path, content, err := (Repositories{Client: client}).Readme(context.Background(), "alice/project", "")
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, ".github/README.md", path)
|
||||
assert.Equal(t, "hello", content)
|
||||
|
||||
_, _, err = (Repositories{Client: client}).Readme(context.Background(), "alice/project", "develp")
|
||||
require.EqualError(t, err, `branch "develp" not found in alice/project`)
|
||||
}
|
||||
Reference in new issue
Block a user