2 Copyright (C) 2018 "IoT.bzh"
3 Author Frédéric Marec <frederic.marec@iot.bzh>
5 Licensed under the Apache License, Version 2.0 (the "License");
6 you may not use this file except in compliance with the License.
7 You may obtain a copy of the License at
9 http://www.apache.org/licenses/LICENSE-2.0
11 Unless required by applicable law or agreed to in writing, software
12 distributed under the License is distributed on an "AS IS" BASIS,
13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 See the License for the specific language governing permissions and
15 limitations under the License.
18 NOTE: strict mode: every global variables should be prefixed by '_'
21 local testPrefix ="persistence_BasicAPITest_"
23 -- This tests the 'insert' verb of the persistence API
24 _AFT.describe(testPrefix.."insert_with_verification",function()
25 _AFT.assertVerbStatusSuccess("persistence", "insert", {key="TESTinsert", value="insert"})
26 _AFT.assertVerbResponseEquals("persistence","read", {key="TESTinsert"},{value="insert"})
27 _AFT.assertVerbStatusSuccess("persistence", "delete", {key="TESTinsert"})
28 _AFT.assertVerbResponseEqualsError("persistence","read", {key="TESTinsert"},{value="insert"})
31 -- This tests the 'update' verb of the persistence API
32 _AFT.describe(testPrefix.."update_with_verification",function()
33 _AFT.assertVerbStatusSuccess("persistence", "insert", {key="TESTupdate", value="myvalue"})
34 _AFT.assertVerbResponseEquals("persistence","read", {key="TESTupdate"},{value="myvalue"})
35 _AFT.assertVerbStatusSuccess("persistence", "update", {key="TESTupdate", value="newvalue"})
36 _AFT.assertVerbResponseEquals("persistence","read", {key="TESTupdate"},{value="newvalue"})
37 _AFT.assertVerbStatusSuccess("persistence", "delete", {key="TESTupdate"})
38 _AFT.assertVerbResponseEqualsError("persistence","read", {key="TESTupdate"},{value="myvalue"})
39 _AFT.assertVerbResponseEqualsError("persistence","read", {key="TESTupdate"},{value="newvalue"})
42 -- This tests the 'delete' verb of the persistence API
43 _AFT.describe(testPrefix.."delete_with_verification",function()
44 _AFT.assertVerbStatusSuccess("persistence", "insert", {key="TESTdelete", value="delete"})
45 _AFT.assertVerbResponseEquals("persistence","read", {key="TESTdelete"},{value="delete"})
46 _AFT.assertVerbStatusSuccess("persistence", "delete", {key="TESTdelete"})
47 _AFT.assertVerbResponseEqualsError("persistence","read", {key="TESTdelete"},{value="delete"})
50 -- This tests the 'insert' verb of the persistence API
51 _AFT.testVerbStatusSuccess(testPrefix.."insert","persistence","insert", {key="TESTinsert", value="insert"}, nil,
53 _AFT.assertVerbStatusSuccess("persistence", "delete", {key="TESTinsert"})
56 -- This tests the 'delete' verb of the persistence API
57 _AFT.testVerbStatusSuccess(testPrefix.."delete","persistence","delete", {key="TESTdelete"},
59 _AFT.assertVerbStatusSuccess("persistence", "insert", {key="TESTdelete", value="delete"})
62 -- This tests the 'update' verb of the persistence API
63 _AFT.testVerbStatusSuccess(testPrefix.."update","persistence","update", {key="TESTupdate", value="testupdate"},
65 _AFT.assertVerbStatusSuccess("persistence", "insert", {key="TESTupdate", value="newupdate"})
68 _AFT.assertVerbStatusSuccess("persistence", "delete", {key="TESTupdate"})
71 -- This tests the 'read' verb of the persistence API
72 _AFT.testVerbStatusSuccess(testPrefix.."read","persistence","read", {key="TESTread"},
74 _AFT.assertVerbStatusSuccess("persistence", "insert", {key="TESTread", value="myvalue"})
77 _AFT.assertVerbStatusSuccess("persistence", "delete", {key="TESTread"})
80 -- This tests the 'read' verb of the persistence API
81 _AFT.testVerbStatusError(testPrefix.."read-unknow-value","persistence","read", {key="TESTread-unknow-value"}, nil, nil)
83 -- This tests the 'insert' verb of the persistence API
84 _AFT.testVerbStatusError(testPrefix.."insert-without-value","persistence","insert", {key="TESTread-unknow-value"}, nil,
86 _AFT.assertVerbStatusError("persistence", "delete", {key="TEST"})
89 -- This tests the 'insert' verb of the persistence API
90 _AFT.testVerbStatusError(testPrefix.."insert-with-wrong_key","persistence","insert", {wrong_key="TESTinsert-wrong-key", value="TESTinsert-wrong-key"}, nil,
92 _AFT.assertVerbStatusError("persistence", "delete", {key="TESTinsert-wrong-key"})
95 -- This tests the 'insert' verb of the persistence API
96 _AFT.testVerbStatusError(testPrefix.."insert-with-wrong_value","persistence","insert", {key="TESTinsert-wrong-value", wrong_value="TESTinsert-wrong-value"}, nil,
98 _AFT.assertVerbStatusError("persistence", "delete", {key="TESTinsert-wrong-value"})
101 -- This tests the 'delete' verb of the persistence API
102 _AFT.testVerbStatusError(testPrefix.."delete-unknow-key","persistence","delete", {key="TESTdelete-unknow-key"}, nil, nil)
104 -- This tests the 'insert' verb of the persistence API
105 _AFT.testVerbStatusError(testPrefix.."insert-with-anything","persistence","insert", {value="TESTinsert-with-anything"}, nil, nil)
107 -- This tests the 'update' verb of the persistence API
108 _AFT.testVerbStatusError(testPrefix.."update-unkwon-null-value","persistence","update", {key=null}, nil, nil)