MCPcopy
hub / github.com/kubernetes/test-infra / TestMakeTable

Function TestMakeTable

robots/coverage/diff/view_test.go:25–77  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

23)
24
25func TestMakeTable(t *testing.T) {
26 type args struct {
27 baseCovList *calculation.CoverageList
28 newCovList *calculation.CoverageList
29 jobName string
30 coverageThreshold float32
31 }
32 tests := []struct {
33 name string
34 args args
35 wantRes string
36 wantIsCoverageLow bool
37 }{
38 {
39 name: "A",
40 args: args{
41 baseCovList: &calculation.CoverageList{
42 Group: []calculation.Coverage{
43 {Name: "a", NumCoveredStmts: 10, NumAllStmts: 100},
44 {Name: "a2", NumCoveredStmts: 12, NumAllStmts: 100},
45 {Name: "c", NumCoveredStmts: 20, NumAllStmts: 100},
46 {Name: "d", NumCoveredStmts: 30, NumAllStmts: 100},
47 },
48 },
49 newCovList: &calculation.CoverageList{
50 Group: []calculation.Coverage{
51 {Name: "a", NumCoveredStmts: 5, NumAllStmts: 100},
52 {Name: "b", NumCoveredStmts: 10, NumAllStmts: 100},
53 {Name: "c", NumCoveredStmts: 20, NumAllStmts: 100},
54 {Name: "d", NumCoveredStmts: 40, NumAllStmts: 100},
55 },
56 },
57 jobName: "example-coverage-test",
58 coverageThreshold: 30,
59 },
60 wantRes: "a | 10.0% | 5.0% | -5.0\n" +
61 "b | Does not exist | 10.0% | \n" +
62 "d | 30.0% | 40.0% | 10.0",
63 wantIsCoverageLow: true,
64 },
65 }
66 for _, tt := range tests {
67 t.Run(tt.name, func(t *testing.T) {
68 gotRes, gotIsCoverageLow := makeTable(tt.args.baseCovList, tt.args.newCovList, tt.args.coverageThreshold)
69 if gotRes != tt.wantRes {
70 t.Errorf("makeTable() gotRes = %v, want %v", gotRes, tt.wantRes)
71 }
72 if gotIsCoverageLow != tt.wantIsCoverageLow {
73 t.Errorf("makeTable() gotIsCoverageLow = %v, want %v", gotIsCoverageLow, tt.wantIsCoverageLow)
74 }
75 })
76 }
77}

Callers

nothing calls this directly

Calls 2

makeTableFunction · 0.85
RunMethod · 0.65

Tested by

no test coverage detected