-
Notifications
You must be signed in to change notification settings - Fork 1
/
testDetectorConfig.go
95 lines (85 loc) · 1.92 KB
/
testDetectorConfig.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
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
package main
import (
"context"
"log"
"github.com/pixlise/core/v4/api/dbCollections"
"github.com/pixlise/core/v4/core/wstestlib"
protos "github.com/pixlise/core/v4/generated-protos"
)
func testDetectorConfig(apiHost string) {
// Seed the DB with a config
configItem := protos.DetectorConfig{
Id: "PIXL",
MinElement: 11,
MaxElement: 92,
XrfeVLowerBound: 800,
XrfeVUpperBound: 20000,
XrfeVResolution: 230,
WindowElement: 14,
TubeElement: 45,
DefaultParams: "",
MmBeamRadius: 0.05999999865889549,
}
db := wstestlib.GetDB()
coll := db.Collection(dbCollections.DetectorConfigsName)
ctx := context.TODO()
err := coll.Drop(ctx)
if err != nil {
log.Fatalln(err)
}
_, err = coll.InsertOne(ctx, &configItem)
if err != nil {
log.Fatalln(err)
}
u1 := wstestlib.MakeScriptedTestUser(auth0Params)
u1.AddConnectAction("Connect", &wstestlib.ConnectInfo{
Host: apiHost,
User: test1Username,
Pass: test1Password,
})
u1.AddSendReqAction("Read non existant config",
`{"detectorConfigReq":{"id": "non-existant"}}`,
`{"msgId":1,
"status": "WS_NOT_FOUND",
"errorText": "non-existant not found",
"detectorConfigResp":{}}`,
)
u1.AddSendReqAction("Read existing config",
`{"detectorConfigReq":{"id": "PIXL"}}`,
`{"msgId":2,
"status":"WS_OK",
"detectorConfigResp":{
"config":
{
"id": "PIXL",
"minElement": 11,
"maxElement": 92,
"xrfeVLowerBound": 800,
"xrfeVUpperBound": 20000,
"xrfeVResolution": 230,
"windowElement": 14,
"tubeElement": 45,
"mmBeamRadius": 0.06
},
"piquantConfigVersions": [
"v5",
"v6",
"v7"
]
}
}`,
)
u1.AddSendReqAction("Read config list",
`{"detectorConfigListReq":{}}`,
`{"msgId":3,
"status":"WS_OK",
"detectorConfigListResp":{
"configs": [
"PIXL"
]
}
}`,
)
u1.CloseActionGroup([]string{}, 5000)
wstestlib.ExecQueuedActions(&u1)
}