-
Notifications
You must be signed in to change notification settings - Fork 90
/
get_test.go
51 lines (39 loc) · 886 Bytes
/
get_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
43
44
45
46
47
48
49
50
51
package main
import (
"os"
"testing"
)
func TestGet(t *testing.T) {
// use custom name so test won't interfere with a real _gen.go
c := defaultConfig
c.customName = "_gen_get_test.go"
// clean up when done
defer os.Remove(c.customName)
// standard
imps, err := getTypewriterImports(c)
if err != nil {
t.Error(err)
}
if len(imps) != 2 {
t.Errorf("should return 2 imports, got %v", len(imps))
}
if err := add(c, "github.com/clipperhouse/foowriter", "github.com/clipperhouse/setwriter"); err != nil {
t.Error(err)
}
// custom file now exists
imps2, err := getTypewriterImports(c)
if err != nil {
t.Error(err)
}
if len(imps2) != 4 {
t.Errorf("should return 4 custom imports, got %v", len(imps2))
}
// custom get
if err := get(c); err != nil {
t.Error(err)
}
// custom get with param
if err := get(c, "-d"); err != nil {
t.Error(err)
}
}