-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathstats_test.go
More file actions
47 lines (42 loc) · 962 Bytes
/
Copy pathstats_test.go
File metadata and controls
47 lines (42 loc) · 962 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package main
import (
"testing"
"github.com/icco/etu/client"
)
func TestFormatStats(t *testing.T) {
personal := client.Stats{TotalBlips: 10, UniqueTags: 5, WordsWritten: 1234}
community := client.Stats{TotalBlips: 1000, UniqueTags: 200, WordsWritten: 99999}
tests := []struct {
name string
personal client.Stats
community *client.Stats
want string
}{
{
"personal only",
personal,
nil,
"Blips: 10\nTags: 5\nWords written: 1234\n",
},
{
"with community block",
personal,
&community,
"Blips: 10\nTags: 5\nWords written: 1234\n\nCommunity\nBlips: 1000\nTags: 200\nWords written: 99999\n",
},
{
"zero values",
client.Stats{},
nil,
"Blips: 0\nTags: 0\nWords written: 0\n",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := formatStats(tt.personal, tt.community)
if got != tt.want {
t.Errorf("formatStats() = %q, want %q", got, tt.want)
}
})
}
}