-
Notifications
You must be signed in to change notification settings - Fork 1
/
main_test.go
66 lines (53 loc) · 1.34 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
56
57
58
59
60
61
62
63
64
65
66
package main
import (
"log"
"os"
"reflect"
"testing"
)
func TestRegistration(t *testing.T) {
err := os.Setenv("ECHGO_POD_NAME", "env-echgo-5fbc57dbc4-gmsk8")
if err != nil {
log.Fatalf("err: %s\n", err)
}
expected := make(map[string]string)
expected["pod_name"] = "env-echgo-5fbc57dbc4-gmsk8"
registered := registerEchgos()
if !reflect.DeepEqual(expected, registered) {
t.Error("ECHGO_POD_NAME was not parsed")
}
err = os.Unsetenv("ECHGO_POD_NAME")
if err != nil {
log.Fatalf("err: %s\n", err)
}
}
func TestIgnoreMessage(t *testing.T) {
err := os.Setenv("ECHGO_MESSAGE", "This shouldn't be seen!")
if err != nil {
log.Fatalf("err: %s\n", err)
}
expected := make(map[string]string)
registered := registerEchgos()
if !reflect.DeepEqual(expected, registered) {
t.Error("ECHGO_MESSAGE Should be skipped.")
}
err = os.Unsetenv("ECHGO_MESSAGE")
if err != nil {
log.Fatalf("err: %s\n", err)
}
}
func TestEchgoEchgo(t *testing.T) {
err := os.Setenv("ECHGO_ECHGO_WHAT", "This shouldn't work, why would you do it?")
if err != nil {
log.Fatalf("err: %s\n", err)
}
expected := make(map[string]string)
registered := registerEchgos()
if !reflect.DeepEqual(expected, registered) {
t.Error("ECHGO_ECHGO_WHAT Should be skipped.")
}
err = os.Unsetenv("ECHGO_ECHGO_WHAT")
if err != nil {
log.Fatalf("err: %s\n", err)
}
}