浏览代码

feat: GET settings, chore: add tests to node-red

chore/proposed-structure
Blaz Smehov 4 周前
父节点
当前提交
7d6d45e6fa
共有 2 个文件被更改,包括 335 次插入0 次删除
  1. +3
    -0
      cmd/decoder/main.go
  2. +332
    -0
      test/node-red-integration-tests/apitest.json

+ 3
- 0
cmd/decoder/main.go 查看文件

@@ -131,7 +131,10 @@ func main() {
case msg := <-chLatest:
fmt.Println("latest msg: ", msg)
case msg := <-chSettings:
appCtx.Settings.Lock.Lock()
appCtx.Settings.Settings = msg
fmt.Println("settings channel: ", msg)
appCtx.Settings.Lock.Unlock()
}
}
}


+ 332
- 0
test/node-red-integration-tests/apitest.json 查看文件

@@ -7,10 +7,85 @@
"info": "",
"env": []
},
{
"id": "de9de6edefcc7ee6",
"type": "group",
"z": "59310844a3cdc638",
"style": {
"stroke": "#999999",
"stroke-opacity": "1",
"fill": "none",
"fill-opacity": "1",
"label": true,
"label-position": "nw",
"color": "#a4a4a4"
},
"nodes": [
"883490d684612591",
"3a198c85c047a80d",
"522c9262dc81a34f",
"2f19e204e95d32b2",
"8a39a884d333343d",
"bfc307bbffd86501",
"368acb55a1372809",
"06586c5ac291f999",
"d8d3d6ee351c3fce",
"b03a9a99c8897f49",
"48eb1b4c5a48a874",
"3b832f5f2a705f87",
"1817099dc85d0c73",
"3b4d5dca9051f727",
"213a0de12ca7b387",
"9095389f88755788",
"668a57a11d34fab9",
"9fe67862caf1033d",
"c52f0e6e0e08f1ca",
"35d94840a12ca741",
"2475de26f85f96e5",
"50c9899be46f95be"
],
"x": 74,
"y": 99,
"w": 892,
"h": 482
},
{
"id": "f03dded513b83b0d",
"type": "group",
"z": "59310844a3cdc638",
"style": {
"stroke": "#999999",
"stroke-opacity": "1",
"fill": "none",
"fill-opacity": "1",
"label": true,
"label-position": "nw",
"color": "#a4a4a4"
},
"nodes": [
"af59b1d57bce5a71",
"1a1c5a74d2fc1538",
"d846952c928cabfd",
"e8f1a6bb67aa191e",
"082bd00a6d8f4bc2",
"04d408c7b56c5004",
"9d98036262ab3bdc",
"39131f3755e4535d",
"8284044fa3903be9",
"09e2fb2b15f80b1d",
"4321534186191e5c",
"29f7ce4208592cc7"
],
"x": 74,
"y": 599,
"w": 892,
"h": 282
},
{
"id": "883490d684612591",
"type": "inject",
"z": "59310844a3cdc638",
"g": "de9de6edefcc7ee6",
"name": "",
"props": [
{
@@ -40,6 +115,7 @@
"id": "3a198c85c047a80d",
"type": "comment",
"z": "59310844a3cdc638",
"g": "de9de6edefcc7ee6",
"name": "Server components test | BEACONS LIST",
"info": "",
"x": 260,
@@ -50,6 +126,7 @@
"id": "522c9262dc81a34f",
"type": "function",
"z": "59310844a3cdc638",
"g": "de9de6edefcc7ee6",
"name": "GET beacons",
"func": "msg.url = \"http://presense-server:1902/api/beacons\";\nmsg.method = \"GET\";\nmsg.payload = \"\";\nreturn msg;",
"outputs": 1,
@@ -70,6 +147,7 @@
"id": "2f19e204e95d32b2",
"type": "http request",
"z": "59310844a3cdc638",
"g": "de9de6edefcc7ee6",
"name": "",
"method": "use",
"ret": "txt",
@@ -94,6 +172,7 @@
"id": "8a39a884d333343d",
"type": "comment",
"z": "59310844a3cdc638",
"g": "de9de6edefcc7ee6",
"name": "GET beacons list",
"info": "",
"x": 180,
@@ -104,6 +183,7 @@
"id": "bfc307bbffd86501",
"type": "inject",
"z": "59310844a3cdc638",
"g": "de9de6edefcc7ee6",
"name": "",
"props": [
{
@@ -133,6 +213,7 @@
"id": "368acb55a1372809",
"type": "function",
"z": "59310844a3cdc638",
"g": "de9de6edefcc7ee6",
"name": "POST beacons",
"func": "msg.url = \"http://presense-server:1902/api/beacons\";\nmsg.method = \"POST\";\nmsg.payload = {\n \"timestamp\": \"2025-07-24T15:00:00.141Z\", \n \"mac\": \"C3000057B9DA\", \n \"rssi\": -66, \n \"rawData\": \"0201060303AAFE1116AAFE20000C392500000601EA01192890\",\n \"Name\": \"Beacon1\",\n \"Beacon_id\": \"1\"\n};\nreturn msg;",
"outputs": 1,
@@ -153,6 +234,7 @@
"id": "06586c5ac291f999",
"type": "http request",
"z": "59310844a3cdc638",
"g": "de9de6edefcc7ee6",
"name": "",
"method": "use",
"ret": "txt",
@@ -177,6 +259,7 @@
"id": "d8d3d6ee351c3fce",
"type": "comment",
"z": "59310844a3cdc638",
"g": "de9de6edefcc7ee6",
"name": "POST beacons list",
"info": "",
"x": 190,
@@ -187,6 +270,7 @@
"id": "b03a9a99c8897f49",
"type": "debug",
"z": "59310844a3cdc638",
"g": "de9de6edefcc7ee6",
"name": "debug 1",
"active": true,
"tosidebar": true,
@@ -203,6 +287,7 @@
"id": "48eb1b4c5a48a874",
"type": "debug",
"z": "59310844a3cdc638",
"g": "de9de6edefcc7ee6",
"name": "debug 2",
"active": true,
"tosidebar": true,
@@ -219,6 +304,7 @@
"id": "3b832f5f2a705f87",
"type": "json",
"z": "59310844a3cdc638",
"g": "de9de6edefcc7ee6",
"name": "",
"property": "payload",
"action": "",
@@ -235,6 +321,7 @@
"id": "1817099dc85d0c73",
"type": "inject",
"z": "59310844a3cdc638",
"g": "de9de6edefcc7ee6",
"name": "",
"props": [
{
@@ -264,6 +351,7 @@
"id": "3b4d5dca9051f727",
"type": "function",
"z": "59310844a3cdc638",
"g": "de9de6edefcc7ee6",
"name": "PUT beacons",
"func": "msg.url = \"http://presense-server:1902/api/beacons\";\nmsg.method = \"PUT\";\nmsg.payload = {\n \"timestamp\": \"2025-07-24T15:00:00.141Z\",\n \"mac\": \"C3000056GSZW\",\n \"rssi\": -76,\n \"rawData\": \"0201060303AAFE1116AAFE20000C392500000601EA01192890\",\n \"Name\": \"Beacon2\",\n \"Beacon_id\": \"2\"\n};\nreturn msg;",
"outputs": 1,
@@ -284,6 +372,7 @@
"id": "213a0de12ca7b387",
"type": "http request",
"z": "59310844a3cdc638",
"g": "de9de6edefcc7ee6",
"name": "",
"method": "use",
"ret": "txt",
@@ -308,6 +397,7 @@
"id": "9095389f88755788",
"type": "comment",
"z": "59310844a3cdc638",
"g": "de9de6edefcc7ee6",
"name": "PUT beacons list",
"info": "",
"x": 180,
@@ -318,6 +408,7 @@
"id": "668a57a11d34fab9",
"type": "debug",
"z": "59310844a3cdc638",
"g": "de9de6edefcc7ee6",
"name": "debug 4",
"active": true,
"tosidebar": true,
@@ -334,6 +425,7 @@
"id": "9fe67862caf1033d",
"type": "inject",
"z": "59310844a3cdc638",
"g": "de9de6edefcc7ee6",
"name": "",
"props": [
{
@@ -363,6 +455,7 @@
"id": "c52f0e6e0e08f1ca",
"type": "function",
"z": "59310844a3cdc638",
"g": "de9de6edefcc7ee6",
"name": "DELETE beacons",
"func": "msg.url = \"http://presense-server:1902/api/beacons/2\";\nmsg.method = \"DELETE\";\nmsg.payload = \"\";\nreturn msg;",
"outputs": 1,
@@ -383,6 +476,7 @@
"id": "35d94840a12ca741",
"type": "http request",
"z": "59310844a3cdc638",
"g": "de9de6edefcc7ee6",
"name": "",
"method": "use",
"ret": "txt",
@@ -407,6 +501,7 @@
"id": "2475de26f85f96e5",
"type": "comment",
"z": "59310844a3cdc638",
"g": "de9de6edefcc7ee6",
"name": "DELETE beacons list",
"info": "",
"x": 200,
@@ -417,6 +512,7 @@
"id": "50c9899be46f95be",
"type": "debug",
"z": "59310844a3cdc638",
"g": "de9de6edefcc7ee6",
"name": "debug 3",
"active": true,
"tosidebar": true,
@@ -428,5 +524,241 @@
"x": 860,
"y": 540,
"wires": []
},
{
"id": "af59b1d57bce5a71",
"type": "inject",
"z": "59310844a3cdc638",
"g": "f03dded513b83b0d",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 180,
"y": 740,
"wires": [
[
"d846952c928cabfd"
]
]
},
{
"id": "1a1c5a74d2fc1538",
"type": "comment",
"z": "59310844a3cdc638",
"g": "f03dded513b83b0d",
"name": "Server components test | SETTINGS",
"info": "",
"x": 240,
"y": 640,
"wires": []
},
{
"id": "d846952c928cabfd",
"type": "function",
"z": "59310844a3cdc638",
"g": "f03dded513b83b0d",
"name": "POST settings",
"func": "msg.url = \"http://presense-server:1902/api/settings\";\nmsg.method = \"POST\";\nmsg.payload = {\n \"location_confidence\": 10,\n \"last_seen_threshold\": 30,\n \"beacon_metrics_size\": 5,\n \"ha_send_interval\": 60,\n \"ha_send_changes_only\": true\n};\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 360,
"y": 740,
"wires": [
[
"e8f1a6bb67aa191e"
]
]
},
{
"id": "e8f1a6bb67aa191e",
"type": "http request",
"z": "59310844a3cdc638",
"g": "f03dded513b83b0d",
"name": "",
"method": "use",
"ret": "txt",
"paytoqs": "ignore",
"url": "",
"tls": "",
"persist": false,
"proxy": "",
"insecureHTTPParser": false,
"authType": "",
"senderr": false,
"headers": [],
"x": 550,
"y": 740,
"wires": [
[
"04d408c7b56c5004"
]
]
},
{
"id": "082bd00a6d8f4bc2",
"type": "comment",
"z": "59310844a3cdc638",
"g": "f03dded513b83b0d",
"name": "POST settings",
"info": "",
"x": 170,
"y": 700,
"wires": []
},
{
"id": "04d408c7b56c5004",
"type": "debug",
"z": "59310844a3cdc638",
"g": "f03dded513b83b0d",
"name": "debug 5",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 860,
"y": 740,
"wires": []
},
{
"id": "9d98036262ab3bdc",
"type": "inject",
"z": "59310844a3cdc638",
"g": "f03dded513b83b0d",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 180,
"y": 840,
"wires": [
[
"39131f3755e4535d"
]
]
},
{
"id": "39131f3755e4535d",
"type": "function",
"z": "59310844a3cdc638",
"g": "f03dded513b83b0d",
"name": "GET settings",
"func": "msg.url = \"http://presense-server:1902/api/settings\";\nmsg.method = \"GET\";\nmsg.payload = \"\";\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 350,
"y": 840,
"wires": [
[
"8284044fa3903be9"
]
]
},
{
"id": "8284044fa3903be9",
"type": "http request",
"z": "59310844a3cdc638",
"g": "f03dded513b83b0d",
"name": "",
"method": "use",
"ret": "txt",
"paytoqs": "ignore",
"url": "",
"tls": "",
"persist": false,
"proxy": "",
"insecureHTTPParser": false,
"authType": "",
"senderr": false,
"headers": [],
"x": 550,
"y": 840,
"wires": [
[
"29f7ce4208592cc7"
]
]
},
{
"id": "09e2fb2b15f80b1d",
"type": "comment",
"z": "59310844a3cdc638",
"g": "f03dded513b83b0d",
"name": "GET settings",
"info": "",
"x": 170,
"y": 800,
"wires": []
},
{
"id": "4321534186191e5c",
"type": "debug",
"z": "59310844a3cdc638",
"g": "f03dded513b83b0d",
"name": "debug 6",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 860,
"y": 840,
"wires": []
},
{
"id": "29f7ce4208592cc7",
"type": "json",
"z": "59310844a3cdc638",
"g": "f03dded513b83b0d",
"name": "",
"property": "payload",
"action": "",
"pretty": false,
"x": 710,
"y": 840,
"wires": [
[
"4321534186191e5c"
]
]
}
]

正在加载...
取消
保存