Skip to content

Commit c4250be

Browse files
committed
[test] RiemannQuery#fun
1 parent c7ef67a commit c4250be

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

test/riemann-query.coffee

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,32 @@ describe "js-ast-test", ->
8080
for expression, expected of expressions
8181
compiled = (js_ast clj_ast ast expression)
8282
expect(compiled).to.equal expected
83+
84+
describe "RiemannQuery#fun", ->
85+
fn = null
86+
expression = "host ~= \"^local[a-z]+\" and state = 1e4"
87+
88+
beforeEach ->
89+
fn = fun ast expression
90+
91+
afterEach ->
92+
fn = null
93+
94+
it "should return a function", ->
95+
expect(fn).to.be.a "function"
96+
97+
it "should return true when an object matches the expression", ->
98+
event =
99+
host: "localhost"
100+
state: 10000
101+
102+
match = fn event
103+
expect(match).to.be.true
104+
105+
it "should return false when an object doesn not match the expression", ->
106+
event =
107+
host: "localhost"
108+
state: 9999
109+
110+
match = fn event
111+
expect(match).to.be.false

0 commit comments

Comments
 (0)