-
Notifications
You must be signed in to change notification settings - Fork 45
/
main_test.go
45 lines (40 loc) · 1.31 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
package main
import (
"testing"
)
func TestStateRestore(t *testing.T) {
// daemon := new(Daemon)
// daemon.init("t.file")
// i1 := new(P2PInstance)
// i2 := new(P2PInstance)
// i1.Args.IP = "10.10.10.10"
// i1.Args.Dev = "vptp1"
// daemon.Instances.update("1", i1)
// i2.Args.IP = "127.0.0.1"
// i2.Args.Dev = "vptp2"
// daemon.Instances.update("2", i2)
// _, err := daemon.Instances.saveInstances("t.file")
// if err != nil {
// t.Errorf("%v", err)
// }
// loaded, err := daemon.Instances.loadInstances("t.file")
// if err != nil {
// t.Errorf("Failed to load instances: %v", err)
// }
// if len(loaded) != 2 {
// t.Errorf("Resulting instances size doesn't match saved. Expecting 2, Received: %d", len(loaded))
// }
// if loaded[0].IP != "10.10.10.10" && loaded[0].IP != "127.0.0.1" {
// t.Errorf("Loaded IP doesn't match saved: %s", loaded[0].IP)
// }
// if loaded[1].IP != "127.0.0.1" && loaded[1].IP != "10.10.10.10" {
// t.Errorf("Loaded IP doesn't match saved: %s", loaded[1].IP)
// }
// if loaded[0].Dev != "vptp1" && loaded[0].Dev != "vptp2" {
// t.Errorf("Loaded device name doesn't match saved: %s", loaded[0].Dev)
// }
// if loaded[1].Dev != "vptp2" && loaded[1].Dev != "vptp1" {
// t.Errorf("Loaded device name doesn't match saved: %s", loaded[1].Dev)
// }
// os.Remove("t.file")
}