github.com/covergates/covergates@v0.2.2-0.20201009050117-42ef8a19fb95/service/perl/coverage_test.go (about) 1 package perl 2 3 import "testing" 4 5 func TestCoverSummary(t *testing.T) { 6 count1 := &coverCount{ 7 Statement: []int{1, 0, 0, 0}, 8 } 9 count2 := &coverCount{ 10 Statement: []int{0, 1, 0, 0}, 11 } 12 run1 := &coverRun{ 13 Name: "/test", 14 Counts: map[string]*coverCount{ 15 "test.pl": count1, 16 }, 17 } 18 run2 := &coverRun{ 19 Name: "/test", 20 Counts: map[string]*coverCount{ 21 "test.pl": count2, 22 }, 23 } 24 db := &coverDB{ 25 Runs: map[string]*coverRun{ 26 "1": run1, 27 "2": run2, 28 }, 29 } 30 summary, err := db.CountSummarize() 31 if err != nil { 32 t.Error(err) 33 return 34 } 35 count, ok := summary["test.pl"] 36 if !ok { 37 t.Log("Cannot found test.pl") 38 t.Fail() 39 return 40 } 41 expectStatement := []int{1, 1, 0, 0} 42 if len(count.Statement) != len(expectStatement) { 43 t.Fail() 44 return 45 } 46 for i, n := range count.Statement { 47 if n != expectStatement[i] { 48 t.Fail() 49 return 50 } 51 } 52 53 }