-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtbb_test.go
55 lines (45 loc) · 1.29 KB
/
tbb_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 tbb_test
import (
"github.com/apperia-de/tbb"
"github.com/stretchr/testify/assert"
"testing"
)
func TestNew(t *testing.T) {
t.Run("should create new tbot", func(t *testing.T) {
cfg := tbb.LoadConfig("test/data/test.config.yml")
tbot := tbb.New(tbb.WithConfig(cfg))
if tbot == nil {
t.Error("should return a new tbot")
}
})
t.Run("should panic create new tbot without config", func(t *testing.T) {
assert.Panics(t, func() { tbb.New() })
})
t.Run("should create new tbot with custom config", func(t *testing.T) {
type CustomConfig struct {
Version string `yaml:"version"`
Username string `yaml:"username"`
Password string `yaml:"password"`
Blacklist []int `yaml:"blacklist"`
}
expected := CustomConfig{
Version: "v0.1.0",
Username: "me",
Password: "keins",
Blacklist: []int{1, 2, 3},
}
customCfg := tbb.LoadCustomConfig[CustomConfig]("test/data/test.custom.config.yml")
tbot := tbb.New(tbb.WithConfig(customCfg))
assert.NotNil(t, tbot)
assert.Equal(t, expected, customCfg.CustomData)
})
}
func ExampleNew() {
type CustomConfig struct {
Version string `yaml:"version"`
Blacklist []string `yaml:"blacklist"`
}
cfg := tbb.LoadCustomConfig[CustomConfig]("config.yml")
tbot := tbb.New(tbb.WithConfig(cfg))
tbot.Start()
}