forked from JNPRAutomate/nitro-tftp
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathconfig_test.go
More file actions
77 lines (69 loc) · 1.82 KB
/
Copy pathconfig_test.go
File metadata and controls
77 lines (69 loc) · 1.82 KB
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
67
68
69
70
71
72
73
74
75
76
77
package main
import (
"encoding/json"
"log"
"testing"
"time"
)
func TestOpenConfig(t *testing.T) {
cfg := NewConfig()
cfg.Open("/home/rcameron/gopath/src/github.com/robwc/nitro-tftp/example_config.cfg")
}
func TestConfigLoad(t *testing.T) {
cfg := NewConfig()
cfg.Open("/home/rcameron/gopath/src/github.com/robwc/nitro-tftp/example_config.cfg")
s := &TFTPServer{}
s.LoadConfig(cfg)
}
func TestConfigMarshal(t *testing.T) {
cfg := NewConfig()
cfg.Open("/home/rcameron/gopath/src/github.com/robwc/nitro-tftp/example_config.cfg")
data, err := json.Marshal(cfg)
if err != nil {
t.Error(err)
}
log.Println(string(data))
}
func TestConfigLoadAndOpen(t *testing.T) {
cfg := NewConfig()
cfg.Open("/home/rcameron/gopath/src/github.com/robwc/nitro-tftp/example_config.cfg")
s := &TFTPServer{}
s.LoadConfig(cfg)
ctrlChan := s.Listen()
timer := time.NewTimer(time.Second * 5)
<-timer.C
close(ctrlChan)
}
func TestConfigLoadDefaultAndOpen(t *testing.T) {
s := &TFTPServer{}
s.LoadConfig(NewConfig())
ctrlChan := s.Listen()
timer := time.NewTimer(time.Second * 5)
<-timer.C
close(ctrlChan)
}
func TestConfigString(t *testing.T) {
cfg := NewConfig()
err := cfg.StringParse(`{incomingdir : ./incoming,outgoingdir : ./outgoing,listenip:0.0.0.0,port:6969,protocol:udp4,stats:true, statsip:127.0.0.1,statsport:126969}`)
if err != nil {
t.Error(err)
}
d, err := json.Marshal(cfg)
if err != nil {
t.Error(err)
}
log.Println(string(d))
}
func TestConfigStringLoad(t *testing.T) {
cfg := &Config{}
err := cfg.StringParse(`{incomingdir : ./incoming,outgoingdir : ./outgoing,listenip:0.0.0.0,port:6969,protocol:udp4,stats:true, statsip:127.0.0.1,statsport:126969}}`)
if err != nil {
t.Error(err)
}
s := &TFTPServer{}
s.LoadConfig(cfg)
ctrlChan := s.Listen()
timer := time.NewTimer(time.Second * 5)
<-timer.C
close(ctrlChan)
}