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.

goget_test.go 937B

123456789101112131415161718192021222324252627282930313233343536
  1. // Copyright 2021 The Gitea Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package integrations
  5. import (
  6. "fmt"
  7. "net/http"
  8. "testing"
  9. "code.gitea.io/gitea/modules/setting"
  10. "github.com/stretchr/testify/assert"
  11. )
  12. func TestGoGet(t *testing.T) {
  13. defer prepareTestEnv(t)()
  14. req := NewRequest(t, "GET", "/blah/glah/plah?go-get=1")
  15. resp := MakeRequest(t, req, http.StatusOK)
  16. expected := fmt.Sprintf(`<!doctype html>
  17. <html>
  18. <head>
  19. <meta name="go-import" content="%[1]s:%[2]s/blah/glah git %[3]sblah/glah.git">
  20. <meta name="go-source" content="%[1]s:%[2]s/blah/glah _ %[3]sblah/glah/src/branch/master{/dir} %[3]sblah/glah/src/branch/master{/dir}/{file}#L{line}">
  21. </head>
  22. <body>
  23. go get --insecure %[1]s:%[2]s/blah/glah
  24. </body>
  25. </html>
  26. `, setting.Domain, setting.HTTPPort, setting.AppURL)
  27. assert.Equal(t, expected, resp.Body.String())
  28. }