-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsupervisorprocesses_test.go
More file actions
100 lines (77 loc) · 2.12 KB
/
supervisorprocesses_test.go
File metadata and controls
100 lines (77 loc) · 2.12 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
package actress
import (
"context"
"fmt"
"testing"
"github.com/fxamacker/cbor/v2"
)
func TestESProcesses(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
testCh := make(chan string)
cfg, _ := NewConfig("debug")
rootp := NewRootProcess(ctx, nil, cfg)
err := rootp.Act()
if err != nil {
t.Fatal(err)
}
NewProcess(ctx, rootp, ETTest, ETTestfn(testCh)).Act()
// NewProcess(ctx, rootp, ESProcesses, KindSupervisor, esProcessesFn()).Act()
md := esProcessesMapDataIn{
Name: "TestType1",
}
// ---------- Add item to the esprocesses map
b, err := cbor.Marshal(md)
if err != nil {
t.Fatalf("error: failed to marshal map data: %v", err)
}
rootp.AddEvent(Event{
Name: ESProcesses,
Instruction: InstructionESProcessesAdd,
Data: b,
NextEvent: &Event{Name: ETTest},
})
// Wait for the the reply back, which are the ETTest .NextEvent
select {
case <-testCh:
case <-ctx.Done():
return
}
// ---------- Get item to the esprocesses map
rootp.AddEvent(Event{
Name: ESProcesses,
Instruction: InstructionESProcessesGetAll,
NextEvent: &Event{Name: ETTest},
})
// Wait for the the reply back, which are the ETTest .NextEvent
select {
case ev := <-testCh:
pm := ESProcessesMap{}
err := cbor.Unmarshal([]byte(ev), &pm)
if err != nil {
t.Fatalf("error: failed to unmarshal process map: %v", err)
}
// TODO: FIX TEST, so it actually tests for something.
if pm["TestType1"] != "TestType1" {
t.Fatalf("The received map did not contain the expected value %+v\n", pm)
}
fmt.Printf("\n###########################################################################\n")
fmt.Printf("# Map contained: %v\n", pm)
fmt.Printf("###########################################################################\n")
case <-ctx.Done():
return
}
// ---------- Delete item from the esprocesses map
rootp.AddEvent(Event{
Name: ESProcesses,
Instruction: InstructionESProcessesDelete,
Data: b,
NextEvent: &Event{Name: ETTest},
})
// Wait for the the reply back, which are the ETTest .NextEvent
select {
case <-testCh:
case <-ctx.Done():
return
}
}