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.

41 lines
945 B

  1. // Copyright 2016 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 models
  5. import (
  6. "testing"
  7. "code.gitea.io/git"
  8. )
  9. func BenchmarkGetCommitGraph(b *testing.B) {
  10. currentRepo, err := git.OpenRepository(".")
  11. if err != nil {
  12. b.Error("Could not open repository")
  13. }
  14. graph, err := GetCommitGraph(currentRepo)
  15. if err != nil {
  16. b.Error("Could get commit graph")
  17. }
  18. if len(graph) < 100 {
  19. b.Error("Should get 100 log lines.")
  20. }
  21. }
  22. func BenchmarkParseCommitString(b *testing.B) {
  23. testString := "* DATA:||4e61bacab44e9b4730e44a6615d04098dd3a8eaf|2016-12-20 21:10:41 +0100|Kjell Kvinge|kjell@kvinge.biz|4e61bac|Add route for graph"
  24. graphItem, err := graphItemFromString(testString, nil)
  25. if err != nil {
  26. b.Error("could not parse teststring")
  27. }
  28. if graphItem.Author != "Kjell Kvinge" {
  29. b.Error("Did not get expected data")
  30. }
  31. }