-
Notifications
You must be signed in to change notification settings - Fork 0
/
yql.unitTestHelper.xml
92 lines (86 loc) · 3.68 KB
/
yql.unitTestHelper.xml
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
<?xml version="1.0"?>
<table xmlns="http://query.yahooapis.com/v1/schema/table.xsd">
<meta>
<author>Aaron Wheeler ([email protected])</author>
<description>Example table for what unit tests look like</description>
<sampleQuery>select * from {table}</sampleQuery>
</meta>
<bindings>
<!--/*
Returns the test suite for yql.unitTestHelper
select * from yql.unit_test_helper where test="unit"
*/-->
<select produces="JSON" itemPath="result.asserts">
<urls><url></url></urls>
<inputs><key id="test" type="xs:string" paramType="variable" required="true" /></inputs>
<execute><![CDATA[
var tests = {asserts: [
{
name : 'Validate assertHasElements helper method',
query : 'SELECT * FROM {table}',
should: {
'pass for long chains' : 'assertHasElements("out.first_set.elt")',
'pass for simple chains' : 'assertHasElements("out.second_set")',
'pass for attributes' : 'assertHasElements("out.first_set.elt.alt")',
'fail otherwise' : '!assertHasElements("out.third_set")'
}
},
{
name : 'Validate assertDoesNotHaveElements helper method',
query : 'SELECT * FROM {table}',
should: {
'pass when missing at the end of the chain' : 'assertDoesNotHaveElements("out.first_set.missing")',
'pass when missing in the middle of a chain' : 'assertDoesNotHaveElements("out.third_set.missing")',
'pass when missing attributes' : 'assertDoesNotHaveElements("out.first_set.elt.src")',
'fail otherwise' : '!assertDoesNotHaveElements("out.second_set")'
}
},
{
name : 'Validate assertHasAtLeastOne helper method',
query : 'SELECT * FROM {table}',
should: {
'pass for a common element' : 'assertHasAtLeastOne("elt", "out.first_set")',
'pass for a unique element' : 'assertHasAtLeastOne("strong", "out.first_set.elt")',
'pass for a common attribute' : 'assertHasAtLeastOne("alt", "out.first_set.elt")',
'pass for a unique attribute' : 'assertHasAtLeastOne("rel", "out.first_set.elt")',
'fail otherwise' : '!assertHasAtLeastOne("foo", "out.first_set")'
}
},
{
name : 'Validate data object',
query : 'SELECT * FROM {table}',
should: {
'pass for simple lookup' : 'data.out.first_set.elt',
'fail for missing simple lookup' : '!data.out.first_set.foo',
'pass for simple computation' : 'data.out.first_set.elt.length == 3',
'fail for wrong simple computation' : '!(data.out.first_set.elt.length == 4)'
}
},
{
name : 'Fail and Error examples',
query : 'SELECT * FROM {table}',
should: {
'print a failure' : 'data.out.first_set.elt.length == 4',
'print an error' : 'data.broken.chain'
}
}
]};
response.object = tests;
]]></execute>
</select>
<select produces="XML" itemPath="">
<urls><url></url></urls>
<inputs></inputs>
<execute><![CDATA[
response.object = <out>
<first_set>
<elt alt="one">Value 1</elt>
<elt alt="two"><strong>Value 2</strong></elt>
<elt alt="three" rel="true">Value 3</elt>
</first_set>
<second_set>2nd</second_set>
</out>;
]]></execute>
</select>
</bindings>
</table>