-
Notifications
You must be signed in to change notification settings - Fork 664
/
Copy pathtest606.js
93 lines (88 loc) · 1.67 KB
/
test606.js
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
if (typeof exports === 'object') {
var assert = require('assert');
var alasql = require('..');
}
var test = 606;
describe('Test ' + test + ' - get autoval', function () {
before(function () {
alasql('create database test' + test);
alasql('use test' + test);
});
after(function () {
alasql('drop database test' + test);
});
it('A) complex SEARCH query', function () {
const data = {
kind: 'PodList',
apiVersion: 'v1',
metadata: {
selfLink: '/api/v1/pods',
},
items: [
{
metadata: {
name: 'pod1',
namespace: 'namespace1',
},
spec: {
volumes: [
{
name: 'default-token',
secret: {
secretName: 'default-token',
},
},
],
nodeName: 'node-1',
},
},
{
metadata: {
name: 'pod2',
namespace: 'namespace2',
},
spec: {
volumes: [
{
name: 'default-token',
secret: {
secretName: 'default-token',
},
},
],
nodeName: 'node-2',
},
},
{
metadata: {
name: 'chosen-pod',
namespace: 'namespace3',
},
spec: {
volumes: [
{
name: 'pod-storage',
},
{
name: 'test-data',
secret: {
secretName: 'test-secret',
},
},
],
nodeName: 'node-2',
},
},
],
};
var res = alasql(
'SEARCH items / AS @a \
spec volumes / WHERE(name="test-data") \
RETURN(@a->metadata->name AS name, \
@a->metadata->namespace AS namespace \
) FROM ?',
[data]
);
assert.deepEqual(res, [{name: 'chosen-pod', namespace: 'namespace3'}]);
});
});