Fork to maintain patches against the official gitea for https://code.ceondo.com https://github.com/go-gitea/gitea

graph_test.go 1021B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. for i := 0; i < b.N; i++ {
  15. graph, err := GetCommitGraph(currentRepo)
  16. if err != nil {
  17. b.Error("Could get commit graph")
  18. }
  19. if len(graph) < 100 {
  20. b.Error("Should get 100 log lines.")
  21. }
  22. }
  23. }
  24. func BenchmarkParseCommitString(b *testing.B) {
  25. testString := "* DATA:||4e61bacab44e9b4730e44a6615d04098dd3a8eaf|2016-12-20 21:10:41 +0100|Kjell Kvinge|kjell@kvinge.biz|4e61bac|Add route for graph"
  26. for i := 0; i < b.N; i++ {
  27. graphItem, err := graphItemFromString(testString, nil)
  28. if err != nil {
  29. b.Error("could not parse teststring")
  30. }
  31. if graphItem.Author != "Kjell Kvinge" {
  32. b.Error("Did not get expected data")
  33. }
  34. }
  35. }