-
Notifications
You must be signed in to change notification settings - Fork 35
/
Copy pathmain_test.go
37 lines (33 loc) · 946 Bytes
/
main_test.go
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
package main
import (
"testing"
)
func TestGetCommandOutput(t *testing.T) {
getCommandOutput("echo test", false)
getCommandOutput("echo 'testline\ncoverage: 35%'", false)
}
func TestBadger(t *testing.T) {
defaultConfig := gopherBadgerConfig{
badgeOutputFlag: true,
badgeStyleFlag: "flat",
updateMdFilesFlag: "",
coveragePrefixFlag: "Go",
coverageCommandFlag: "echo 'testline\ncoverage: 35%'",
manualCoverageFlag: 90,
rootFolderFlag: ".",
tagsFlag: "",
shortFlag: false,
}
badger(defaultConfig)
}
func TestDrawBadge(t *testing.T) {
drawBadge(22.7, "test_badge.png")
drawBadge(88, "test_badge.png")
drawBadge(66, "test_badge.png")
if drawBadge(66, "bad_folder/test_badge.png") == nil {
t.Error("Should respond with error when saving to invalid folder")
}
if drawBadge(-34, "test_badge.png") == nil {
t.Error("Should respond with error when coverage is less than 0")
}
}