node-red-contrib-influxdb3 1.0.7 → 1.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/influxdb3.js +4 -2
- package/package.json +9 -1
- package/__tests__/influxdb3.test.js +0 -1294
- package/renovate.json +0 -14
- package/test/line-protocol-validation.test.js +0 -61
- package/test/point-api.test.js +0 -69
package/renovate.json
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
|
|
3
|
-
"extends": [
|
|
4
|
-
"config:base"
|
|
5
|
-
],
|
|
6
|
-
"platformAutomerge": true,
|
|
7
|
-
"packageRules": [
|
|
8
|
-
{
|
|
9
|
-
"description": "Automerge non-major updates",
|
|
10
|
-
"matchUpdateTypes": ["minor", "patch"],
|
|
11
|
-
"automerge": true
|
|
12
|
-
}
|
|
13
|
-
]
|
|
14
|
-
}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tests for line protocol string validation.
|
|
3
|
-
* Imports the real validateLineProtocol from the shipping code so the test
|
|
4
|
-
* cannot drift from the implementation.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
const { validateLineProtocol } = require('../lib/line-protocol');
|
|
8
|
-
|
|
9
|
-
describe('Line protocol string validation', () => {
|
|
10
|
-
test('valid line protocol returns null', () => {
|
|
11
|
-
expect(validateLineProtocol('weather,location=us-midwest temperature=82 1465839830100400200')).toBeNull();
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
test('valid line protocol without timestamp returns null', () => {
|
|
15
|
-
expect(validateLineProtocol('weather,location=us-midwest temperature=82')).toBeNull();
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
test('valid line protocol without tags returns null', () => {
|
|
19
|
-
expect(validateLineProtocol('weather temperature=82')).toBeNull();
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
test('valid line protocol with multiple fields returns null', () => {
|
|
23
|
-
expect(validateLineProtocol('weather temperature=82,humidity=71')).toBeNull();
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
test('detects JSON object string', () => {
|
|
27
|
-
const input = '{"fields":{"used":12.0},"tags":{"location":"office"}}';
|
|
28
|
-
const result = validateLineProtocol(input);
|
|
29
|
-
expect(result).toContain('JSON/object string');
|
|
30
|
-
expect(result).toContain('not line protocol');
|
|
31
|
-
expect(result).toContain('JSON parse node');
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
test('detects JS object notation string (unquoted keys)', () => {
|
|
35
|
-
const input = '{fields:{used:12.0,path:root},tags:{location:office,node:grafana2}}';
|
|
36
|
-
const result = validateLineProtocol(input);
|
|
37
|
-
expect(result).toContain('JSON/object string');
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
test('detects JSON array string', () => {
|
|
41
|
-
const input = '[{"measurement":"test","fields":{"value":1}}]';
|
|
42
|
-
const result = validateLineProtocol(input);
|
|
43
|
-
expect(result).toContain('JSON/object string');
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
test('detects string with no space (not line protocol)', () => {
|
|
47
|
-
const result = validateLineProtocol('justameasurement');
|
|
48
|
-
expect(result).toContain('does not appear to be valid line protocol');
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
test('detects string with no equals sign (not line protocol)', () => {
|
|
52
|
-
const result = validateLineProtocol('measurement nofields');
|
|
53
|
-
expect(result).toContain('does not appear to be valid line protocol');
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
test('truncates long strings in error message', () => {
|
|
57
|
-
const longJson = '{' + '"a":1,'.repeat(50) + '"b":2}';
|
|
58
|
-
const result = validateLineProtocol(longJson);
|
|
59
|
-
expect(result).toContain('...');
|
|
60
|
-
});
|
|
61
|
-
});
|
package/test/point-api.test.js
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
const { Point } = require('@influxdata/influxdb3-client');
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Pins the real @influxdata/influxdb3-client Point API that influxdb3.js depends on.
|
|
5
|
-
* The node uses the type-specific setters (setFloatField / setIntegerField /
|
|
6
|
-
* setStringField / setBooleanField / setTag / setTimestamp) and toLineProtocol(),
|
|
7
|
-
* so those are what we verify here — if the library changes them, this suite fails.
|
|
8
|
-
*/
|
|
9
|
-
describe('@influxdata/influxdb3-client v2.x Point API used by influxdb3.js', () => {
|
|
10
|
-
test('setFloatField writes a float field', () => {
|
|
11
|
-
const lp = new Point('test').setFloatField('temp', 23.5).toLineProtocol();
|
|
12
|
-
expect(lp).toContain('temp=23.5');
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
test('setFloatField keeps whole numbers as floats (no i suffix)', () => {
|
|
16
|
-
const lp = new Point('test').setFloatField('count', 60).toLineProtocol();
|
|
17
|
-
expect(lp).toContain('count=60');
|
|
18
|
-
expect(lp).not.toContain('count=60i');
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
test('setIntegerField writes an integer field with the i suffix', () => {
|
|
22
|
-
const lp = new Point('test').setIntegerField('count', 42).toLineProtocol();
|
|
23
|
-
expect(lp).toContain('count=42i');
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
test('setIntegerField supports negative integers', () => {
|
|
27
|
-
const lp = new Point('test').setIntegerField('offset', -7).toLineProtocol();
|
|
28
|
-
expect(lp).toContain('offset=-7i');
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
test('setStringField writes a quoted string field', () => {
|
|
32
|
-
const lp = new Point('test').setStringField('status', 'ok').toLineProtocol();
|
|
33
|
-
expect(lp).toContain('status="ok"');
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
test('setBooleanField writes a boolean field', () => {
|
|
37
|
-
const lp = new Point('test').setBooleanField('active', true).toLineProtocol();
|
|
38
|
-
// Library serializes booleans as T/F in line protocol
|
|
39
|
-
expect(lp).toContain('active=T');
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
test('setTag writes a tag in the measurement,tag=value section', () => {
|
|
43
|
-
const lp = new Point('test')
|
|
44
|
-
.setTag('location', 'room1')
|
|
45
|
-
.setFloatField('value', 1)
|
|
46
|
-
.toLineProtocol();
|
|
47
|
-
expect(lp).toContain('test,location=room1 ');
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
test('setTimestamp accepts a Date and appends a nanosecond timestamp', () => {
|
|
51
|
-
const lp = new Point('test')
|
|
52
|
-
.setFloatField('value', 1)
|
|
53
|
-
.setTimestamp(new Date(1700000000000))
|
|
54
|
-
.toLineProtocol();
|
|
55
|
-
// 1700000000000 ms -> 1700000000000000000 ns
|
|
56
|
-
expect(lp).toContain('1700000000000000000');
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
test('the setters used by the node are all functions', () => {
|
|
60
|
-
const point = new Point('test');
|
|
61
|
-
expect(typeof point.setFloatField).toBe('function');
|
|
62
|
-
expect(typeof point.setIntegerField).toBe('function');
|
|
63
|
-
expect(typeof point.setStringField).toBe('function');
|
|
64
|
-
expect(typeof point.setBooleanField).toBe('function');
|
|
65
|
-
expect(typeof point.setTag).toBe('function');
|
|
66
|
-
expect(typeof point.setTimestamp).toBe('function');
|
|
67
|
-
expect(typeof point.toLineProtocol).toBe('function');
|
|
68
|
-
});
|
|
69
|
-
});
|