-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathcove_test.go
42 lines (33 loc) · 990 Bytes
/
cove_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
38
39
40
41
42
package cove
import (
"io/ioutil"
"os"
"path/filepath"
"testing"
)
func TestCoverageProfileDoesntDeleteNonProfileFilesInOutputDir(t *testing.T) {
testdir, _ := ioutil.TempDir("", "coverage-profile")
defer os.RemoveAll(testdir)
bytes := []byte("foo")
foofile := filepath.Join(testdir, "foo")
ioutil.WriteFile(foofile, bytes, 0644)
profile, _ := CoverageProfile(true, "count", testdir, "text/scanner")
if profile == "" {
t.Errorf("Could not create profile")
}
if _, err := os.Stat(foofile); os.IsNotExist(err) {
t.Errorf("Foo file was deleted")
}
}
func TestCoverageProfileCreatesOutputDirIfItDoesntExist(t *testing.T) {
testdir, _ := ioutil.TempDir("", "coverage-profile")
defer os.RemoveAll(testdir)
outdir := filepath.Join(testdir, "outdir")
profile, er := CoverageProfile(true, "set", outdir, "text/scanner")
if er != nil {
t.Errorf("%v", er)
}
if filepath.Dir(profile) != outdir {
t.Errorf("Could not create profile %v in %v", profile, outdir)
}
}