-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain_test.go
47 lines (43 loc) · 886 Bytes
/
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
package main
import (
"fmt"
"testing"
"time"
"github.com/mrod502/ddns/client"
"github.com/mrod502/ddns/config"
"github.com/mrod502/ddns/server"
)
func TestMain(t *testing.T) {
s := server.New(config.Config{
CertFilePath: "cert.pem",
KeyFilePath: "key.pem",
Port: 3391,
PrivateKeyPath: "util/ddns_key",
PublicKeyPath: "util/ddns_key.pub",
APIKey: "LemmeIn",
})
go func() {
err := s.Start()
if err != nil {
fmt.Println("FAILED TO SERVE", err.Error())
t.Fatal(err)
}
}()
time.Sleep(100 * time.Millisecond)
cli := client.New(config.Config{
PingInterval: time.Second,
Port: 3391,
RemoteHost: "localhost",
PublicKeyPath: "util/ddns_key.pub",
})
go func() {
if err := cli.Start(); err != nil {
t.Fatal(err)
}
}()
time.Sleep(time.Second * 3)
err := cli.Ping()
if err != nil {
t.Fatal(err)
}
}