github.com/covergates/covergates@v0.2.2-0.20201009050117-42ef8a19fb95/modules/charts/card_test.go (about) 1 package charts 2 3 import ( 4 "os" 5 "testing" 6 "time" 7 8 "github.com/covergates/covergates/core" 9 ) 10 11 func TestCard(t *testing.T) { 12 card := NewRepoCard( 13 &core.Repo{ 14 NameSpace: "covergates", 15 Name: "covergates", 16 Branch: "master", 17 }, &core.Report{ 18 Files: []string{"main.go", "core.go"}, 19 CreatedAt: time.Date(2020, time.July, 20, 12, 12, 40, 0, time.Local), 20 Coverages: []*core.CoverageReport{ 21 { 22 Files: []*core.File{ 23 { 24 StatementCoverage: 0.8, 25 }, 26 }, 27 }, 28 }, 29 }, 30 ) 31 file, err := os.Create("card.svg") 32 if err != nil { 33 t.Fatal(err) 34 } 35 defer func() { 36 file.Close() 37 os.Remove(file.Name()) 38 }() 39 card.Render(file) 40 }