You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

git_clone_wiki_test.go 1.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. // Copyright 2021 The Gitea Authors. All rights reserved.
  2. // SPDX-License-Identifier: MIT
  3. package integration
  4. import (
  5. "context"
  6. "fmt"
  7. "net/url"
  8. "os"
  9. "path/filepath"
  10. "testing"
  11. "code.gitea.io/gitea/modules/git"
  12. "code.gitea.io/gitea/modules/util"
  13. "code.gitea.io/gitea/tests"
  14. "github.com/stretchr/testify/assert"
  15. )
  16. func assertFileExist(t *testing.T, p string) {
  17. exist, err := util.IsExist(p)
  18. assert.NoError(t, err)
  19. assert.True(t, exist)
  20. }
  21. func assertFileEqual(t *testing.T, p string, content []byte) {
  22. bs, err := os.ReadFile(p)
  23. assert.NoError(t, err)
  24. assert.EqualValues(t, content, bs)
  25. }
  26. func TestRepoCloneWiki(t *testing.T) {
  27. onGiteaRun(t, func(t *testing.T, u *url.URL) {
  28. defer tests.PrepareTestEnv(t)()
  29. dstPath := t.TempDir()
  30. r := fmt.Sprintf("%suser2/repo1.wiki.git", u.String())
  31. u, _ = url.Parse(r)
  32. u.User = url.UserPassword("user2", userPassword)
  33. t.Run("Clone", func(t *testing.T) {
  34. assert.NoError(t, git.CloneWithArgs(context.Background(), git.AllowLFSFiltersArgs(), u.String(), dstPath, git.CloneRepoOptions{}))
  35. assertFileEqual(t, filepath.Join(dstPath, "Home.md"), []byte("# Home page\n\nThis is the home page!\n"))
  36. assertFileExist(t, filepath.Join(dstPath, "Page-With-Image.md"))
  37. assertFileExist(t, filepath.Join(dstPath, "Page-With-Spaced-Name.md"))
  38. assertFileExist(t, filepath.Join(dstPath, "images"))
  39. assertFileExist(t, filepath.Join(dstPath, "jpeg.jpg"))
  40. })
  41. })
  42. }