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.

repo_commits_search_test.go 1.2KB

12345678910111213141516171819202122232425262728293031323334353637
  1. // Copyright 2019 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. "net/http"
  7. "net/url"
  8. "strings"
  9. "testing"
  10. "github.com/stretchr/testify/assert"
  11. )
  12. func testRepoCommitsSearch(t *testing.T, query, commit string) {
  13. prepareTestEnv(t)
  14. session := loginUser(t, "user2")
  15. // Request repository commits page
  16. req := NewRequestf(t, "GET", "/user2/commits_search_test/commits/branch/master/search?q=%s", url.QueryEscape(query))
  17. resp := session.MakeRequest(t, req, http.StatusOK)
  18. doc := NewHTMLParser(t, resp.Body)
  19. sel := doc.doc.Find("#commits-table tbody tr td.sha a")
  20. assert.EqualValues(t, commit, strings.TrimSpace(sel.Text()))
  21. }
  22. func TestRepoCommitsSearch(t *testing.T) {
  23. testRepoCommitsSearch(t, "author:alice", "6e8eabd9a7")
  24. testRepoCommitsSearch(t, "committer:Tom", "58e97d1a24")
  25. testRepoCommitsSearch(t, "author:bob commit-4", "58e97d1a24")
  26. testRepoCommitsSearch(t, "author:bob commit after:2019-03-03", "58e97d1a24")
  27. testRepoCommitsSearch(t, "committer:alice commit before:2019-03-02", "6e8eabd9a7")
  28. testRepoCommitsSearch(t, "committer:alice author:tom commit before:2019-03-04 after:2019-03-02", "0a8499a22a")
  29. }