-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_test.go
55 lines (48 loc) · 1.24 KB
/
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package main
import (
"fmt"
"testing"
"github.com/yonkornilov/snowcapper/config"
"github.com/yonkornilov/snowcapper/context"
"github.com/yonkornilov/snowcapper/runner"
)
func TestConfigBinData(t *testing.T) {
_, err := Asset("config.snc")
if err != nil {
t.Fatal(fmt.Sprint("Expecting no error, got \n%s", err))
}
}
func TestConfigNew(t *testing.T) {
configYaml, _ := Asset("config.snc")
_, err := config.New(configYaml)
if err != nil {
t.Fatal(fmt.Sprint("Expecting no error, got \n%s", err))
}
}
func TestRunnerNew(t *testing.T) {
configYaml, _ := Asset("config.snc")
conf, _ := config.New(configYaml)
ctx := context.New(true)
_, err := runner.New(&ctx, conf)
if err != nil {
t.Fatal(fmt.Sprint("Expecting no error, got \n%s", err))
}
}
func TestRunnerCommandErr(t *testing.T) {
configYaml, _ := Asset("config.snc")
conf, _ := config.New(configYaml)
ctx := context.New(true)
ctx, err := context.CommandErr(ctx)
if err != nil {
t.Fatal(fmt.Sprint("Expecting no error, got \n%s", err))
}
r, err := runner.New(&ctx, conf)
if err != nil {
t.Fatal(fmt.Sprint("Expecting no error, got \n%s", err))
}
err = r.Run()
if err == nil {
t.Fatal("Expect error, got nothing")
}
t.Logf("Got expected command error: %s\n", err)
}