1/*
2 * Copyright (c) 2022 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
16import factory from '@ohos.data.distributedKVStore'
17import abilityFeatureAbility from '@ohos.ability.featureAbility'
18
19var context = abilityFeatureAbility.getContext();
20const TEST_BUNDLE_NAME = 'com.example.myapplication';
21const TEST_STORE_ID = 'storeId';
22const STORE_KEY = 'key_test_string';
23const STORE_VALUE = 'value-test-string';
24var kvManager = null;
25var kvStore = null;
26
27describe('kvManagerCallbackTest', function () {
28    const config = {
29        bundleName: TEST_BUNDLE_NAME,
30        context: context
31    }
32
33    const options = {
34        createIfMissing: true,
35        encrypt: false,
36        backup: false,
37        autoSync: true,
38        kvStoreType: factory.KVStoreType.SINGLE_VERSION,
39        schema: '',
40        securityLevel: factory.SecurityLevel.S2,
41    }
42
43    beforeAll(async function (done) {
44        console.info('beforeAll');
45        kvManager = factory.createKVManager(config);
46        console.info('beforeAll end');
47        done();
48    })
49
50    afterAll(async function (done) {
51        console.info('afterAll');
52        done();
53    })
54
55    beforeEach(async function (done) {
56        console.info('beforeEach');
57        done();
58    })
59
60    afterEach(async function (done) {
61        console.info('afterEach');
62        await kvManager.closeKVStore(TEST_BUNDLE_NAME, TEST_STORE_ID, async function () {
63            console.info('afterEach closeKVStore success');
64            await kvManager.deleteKVStore(TEST_BUNDLE_NAME, TEST_STORE_ID, function () {
65                console.info('afterEach deleteKVStore success');
66                done();
67            });
68        });
69        kvStore = null;
70    })
71
72    /**
73     * @tc.name KVManagerGetKVStoreCallbackSucTest
74     * @tc.desc Test Js Api KVManager.GetKVStore() successfully
75     * @tc.type: FUNC
76     * @tc.require: issueNumber
77     */
78    it('KVManagerGetKVStoreCallbackSucTest', 0, async function (done) {
79        console.info('KVManagerGetKVStoreCallbackSucTest');
80        try {
81            await kvManager.getKVStore(TEST_STORE_ID, options, function (err, store) {
82                console.info('KVManagerGetKVStoreCallbackSucTest getKVStore success');
83                expect(true).assertTrue();
84                kvStore = store;
85                done();
86            });
87        } catch (e) {
88            console.error('KVManagerGetKVStoreCallbackSucTest getKVStore e ' + `, error code is ${e.code}, message is ${e.message}`);
89            expect(null).assertFail();
90            done();
91        }
92    })
93
94    /**
95     * @tc.name KVManagerGetKVStoreCallbackSucTest
96     * @tc.desc Test Js Api KVManager.GetKVStore() successfully
97     * @tc.type: FUNC
98     * @tc.require: issueNumber
99     */
100    it('KVManagerGetKVStoreCallbackSucTest1', 0, async function (done) {
101        console.info('KVManagerGetKVStoreCallbackSucTest');
102        try {
103            await kvManager.getKVStore(TEST_STORE_ID, options, function (err, store) {
104                console.info('KVManagerGetKVStoreCallbackSucTest11 getKVStore success');
105                expect((err == undefined) && (store != null)).assertTrue();
106            });
107            const optionsInfo = {
108                createIfMissing: true,
109                encrypt: false,
110                backup: false,
111                autoSync: true,
112                kvStoreType: factory.KVStoreType.DEVICE_COLLABORATION,
113                schema: '',
114                securityLevel: factory.SecurityLevel.S1,
115            }
116            await kvManager.getKVStore(TEST_STORE_ID, optionsInfo, function (err) {
117                if (err == undefined) {
118                    console.info('KVManagerGetKVStoreCallbackSucTest12 getKVStore success');
119                    expect(null).assertFail();
120                } else {
121                    console.info("throw exception success");
122                    expect(err.code == 15100002).assertTrue();
123                }
124            });
125        } catch (e) {
126            console.error('KVManagerGetKVStoreCallbackSucTest1 getKVStore e ' + `, error code is ${e.code}, message is ${e.message}`);
127            expect(e.code == 15100002).assertTrue();
128        }
129        done();
130    })
131
132    /**
133     * @tc.name KVManagerGetKVStoreCallbackParameterErrorTest
134     * @tc.desc Test Js Api KVManager.GetKVStore() with parameter error
135     * @tc.type: FUNC
136     * @tc.require: issueNumber
137     */
138    it('KVManagerGetKVStoreCallbackParameterErrorTest', 0, async function (done) {
139        console.info('KVManagerGetKVStoreCallbackParameterErrorTest');
140        try {
141            await kvManager.getKVStore(options, function () {
142                expect(null).assertFail();
143            });
144        } catch (e) {
145            console.error('KVManagerGetKVStoreCallbackParameterErrorTest getKVStore e ' + `, error code is ${e.code}, message is ${e.message}`);
146            expect(e.code == 401).assertTrue();
147            done();
148        }
149    })
150
151    /**
152     * @tc.name KVManagerGetKVStoreCallbackDeviceS1SucTest
153     * @tc.desc Test Js Api KVManager.GetKVStore() device S1
154     * @tc.type: FUNC
155     * @tc.require: issueNumber
156     */
157    it('KVManagerGetKVStoreCallbackDeviceS1SucTest', 0, async function (done) {
158        console.info('KVManagerGetKVStoreCallbackDeviceS1SucTest');
159        const optionsInfo = {
160            createIfMissing: true,
161            encrypt: true,
162            backup: false,
163            autoSync: true,
164            kvStoreType: factory.KVStoreType.DEVICE_COLLABORATION,
165            schema: '',
166            securityLevel: factory.SecurityLevel.S1,
167        }
168        try {
169            await kvManager.getKVStore(TEST_STORE_ID, optionsInfo, function (err, store) {
170                console.info('KVManagerGetKVStoreCallbackDeviceS1SucTest getKVStore success');
171                expect((err == undefined) && (store != null)).assertTrue();
172                done();
173            });
174        } catch (e) {
175            console.error('KVManagerGetKVStoreCallbackDeviceS1SucTest getKVStore e ' + `, error code is ${e.code}, message is ${e.message}`);
176            expect(null).assertFail();
177            done();
178        }
179    })
180
181    /**
182     * @tc.name KVManagerGetKVStoreCallbackDeviceS2SucTest
183     * @tc.desc Test Js Api KVManager.GetKVStore() device s2
184     * @tc.type: FUNC
185     * @tc.require: issueNumber
186     */
187    it('KVManagerGetKVStoreCallbackDeviceS2SucTest', 0, async function (done) {
188        console.info('KVManagerGetKVStoreCallbackDeviceS2SucTest');
189        const optionsInfo = {
190            createIfMissing: true,
191            encrypt: false,
192            backup: false,
193            autoSync: true,
194            kvStoreType: factory.KVStoreType.DEVICE_COLLABORATION,
195            schema: '',
196            securityLevel: factory.SecurityLevel.S2,
197        }
198        try {
199            await kvManager.getKVStore(TEST_STORE_ID, optionsInfo, function (err, store) {
200                console.info('KVManagerGetKVStoreCallbackDeviceS2SucTest getKVStore success');
201                expect((err == undefined) && (store != null)).assertTrue();
202                done();
203            });
204        } catch (e) {
205            console.error('KVManagerGetKVStoreCallbackDeviceS2SucTest getKVStore e ' + `, error code is ${e.code}, message is ${e.message}`);
206            expect(null).assertFail();
207            done();
208        }
209    })
210
211    /**
212     * @tc.name KVManagerGetKVStoreCallbackDeviceS3SucTest
213     * @tc.desc Test Js Api KVManager.GetKVStore() device s3
214     * @tc.type: FUNC
215     * @tc.require: issueNumber
216     */
217    it('KVManagerGetKVStoreCallbackDeviceS3SucTest', 0, async function (done) {
218        console.info('KVManagerGetKVStoreCallbackDeviceS3SucTest');
219        const optionsInfo = {
220            createIfMissing: true,
221            encrypt: false,
222            backup: true,
223            autoSync: true,
224            kvStoreType: factory.KVStoreType.DEVICE_COLLABORATION,
225            schema: '',
226            securityLevel: factory.SecurityLevel.S3,
227        }
228        try {
229            await kvManager.getKVStore(TEST_STORE_ID, optionsInfo, function (err, store) {
230                console.info('KVManagerGetKVStoreCallbackDeviceS3SucTest getKVStore success');
231                expect((err == undefined) && (store != null)).assertTrue();
232                kvStore = store;
233                done();
234            });
235        } catch (e) {
236            console.error('KVManagerGetKVStoreCallbackDeviceS3SucTest getKVStore e ' + `, error code is ${e.code}, message is ${e.message}`);
237            expect(null).assertFail();
238            done();
239        }
240    })
241
242    /**
243     * @tc.name KVManagerGetKVStoreCallbackDeviceS4SucTest
244     * @tc.desc Test Js Api KVManager.GetKVStore() device s4
245     * @tc.type: FUNC
246     * @tc.require: issueNumber
247     */
248    it('KVManagerGetKVStoreCallbackDeviceS4SucTest', 0, async function (done) {
249        console.info('KVManagerGetKVStoreCallbackDeviceS4SucTest');
250        const optionsInfo = {
251            createIfMissing: true,
252            encrypt: false,
253            backup: false,
254            autoSync: true,
255            kvStoreType: factory.KVStoreType.DEVICE_COLLABORATION,
256            schema: '',
257            securityLevel: factory.SecurityLevel.S4,
258        }
259        try {
260            await kvManager.getKVStore(TEST_STORE_ID, optionsInfo, function (err, store) {
261                console.info('KVManagerGetKVStoreCallbackDeviceS4SucTest getKVStore success');
262                expect((err == undefined) && (store != null)).assertTrue();
263                done();
264            });
265        } catch (e) {
266            console.error('KVManagerGetKVStoreCallbackDeviceS4SucTest getKVStore e ' + `, error code is ${e.code}, message is ${e.message}`);
267            expect(null).assertFail();
268            done();
269        }
270    })
271
272    /**
273     * @tc.name KVManagerGetKVStoreCallbackSingleS1SucTest
274     * @tc.desc Test Js Api KVManager.GetKVStore() singleversion s1
275     * @tc.type: FUNC
276     * @tc.require: issueNumber
277     */
278    it('KVManagerGetKVStoreCallbackSingleS1SucTest', 0, async function (done) {
279        console.info('KVManagerGetKVStoreCallbackSingleS1SucTest');
280        const optionsInfo = {
281            createIfMissing: true,
282            encrypt: false,
283            backup: false,
284            autoSync: true,
285            kvStoreType: factory.KVStoreType.SINGLE_VERSION,
286            schema: '',
287            securityLevel: factory.SecurityLevel.S1,
288        }
289        try {
290            await kvManager.getKVStore(TEST_STORE_ID, optionsInfo, function (err, store) {
291                console.info('KVManagerGetKVStoreCallbackSingleS1SucTest getKVStore success');
292                expect((err == undefined) && (store != null)).assertTrue();
293                done();
294            });
295        } catch (e) {
296            console.error('KVManagerGetKVStoreCallbackSingleS1SucTest getKVStore e ' + `, error code is ${e.code}, message is ${e.message}`);
297            expect(null).assertFail();
298            done();
299        }
300    })
301
302    /**
303     * @tc.name KVManagerGetKVStoreCallbackSingleS2SucTest
304     * @tc.desc Test Js Api KVManager.GetKVStore() singleversion s2
305     * @tc.type: FUNC
306     * @tc.require: issueNumber
307     */
308    it('KVManagerGetKVStoreCallbackSingleS2SucTest', 0, async function (done) {
309        console.info('KVManagerGetKVStoreCallbackSingleS2SucTest');
310        const optionsInfo = {
311            createIfMissing: true,
312            encrypt: false,
313            backup: false,
314            autoSync: true,
315            kvStoreType: factory.KVStoreType.SINGLE_VERSION,
316            schema: '',
317            securityLevel: factory.SecurityLevel.S2,
318        }
319        try {
320            await kvManager.getKVStore(TEST_STORE_ID, optionsInfo, function (err, store) {
321                console.info('KVManagerGetKVStoreCallbackSingleS2SucTest getKVStore success');
322                expect((err == undefined) && (store != null)).assertTrue();
323                done();
324            });
325        } catch (e) {
326            console.error('KVManagerGetKVStoreCallbackSingleS2SucTest getKVStore e ' + `, error code is ${e.code}, message is ${e.message}`);
327            expect(null).assertFail();
328            done();
329        }
330    })
331
332    /**
333     * @tc.name KVManagerGetKVStoreCallbackSingleS3SucTest
334     * @tc.desc Test Js Api KVManager.GetKVStore() singleversion s3
335     * @tc.type: FUNC
336     * @tc.require: issueNumber
337     */
338    it('KVManagerGetKVStoreCallbackSingleS3SucTest', 0, async function (done) {
339        console.info('KVManagerGetKVStoreCallbackSingleS3SucTest');
340        const optionsInfo = {
341            createIfMissing: true,
342            encrypt: false,
343            backup: false,
344            autoSync: true,
345            kvStoreType: factory.KVStoreType.SINGLE_VERSION,
346            schema: '',
347            securityLevel: factory.SecurityLevel.S3,
348        }
349        try {
350            await kvManager.getKVStore(TEST_STORE_ID, optionsInfo, function (err, store) {
351                console.info('KVManagerGetKVStoreCallbackSingleS3SucTest getKVStore success');
352                expect((err == undefined) && (store != null)).assertTrue();
353                done();
354            });
355        } catch (e) {
356            console.error('KVManagerGetKVStoreCallbackSingleS3SucTest getKVStore e ' + `, error code is ${e.code}, message is ${e.message}`);
357            done();
358        }
359    })
360
361    /**
362     * @tc.name KVManagerGetKVStoreCallbackSingleS4SucTest
363     * @tc.desc Test Js Api KVManager.GetKVStore() singleversion s4
364     * @tc.type: FUNC
365     * @tc.require: issueNumber
366     */
367    it('KVManagerGetKVStoreCallbackSingleS4SucTest', 0, async function (done) {
368        console.info('KVManagerGetKVStoreCallbackSingleS4SucTest');
369        const optionsInfo = {
370            createIfMissing: true,
371            encrypt: false,
372            backup: false,
373            autoSync: true,
374            kvStoreType: factory.KVStoreType.SINGLE_VERSION,
375            schema: '',
376            securityLevel: factory.SecurityLevel.S4,
377        }
378        try {
379            await kvManager.getKVStore(TEST_STORE_ID, optionsInfo, function (err, store) {
380                console.info('KVManagerGetKVStoreCallbackSingleS4SucTest getKVStore success');
381                expect((err == undefined) && (store != null)).assertTrue();
382                done();
383            });
384        } catch (e) {
385            console.error('KVManagerGetKVStoreCallbackSingleS4SucTest getKVStore e ' + `, error code is ${e.code}, message is ${e.message}`);
386            expect(null).assertFail();
387            done();
388        }
389    })
390    /**
391     * @tc.name KVManagerCloseKVStoreCallbackParaErrorTest
392     * @tc.desc Test Js Api KVManager.CloseKVStore() with parameter error
393     * @tc.type: FUNC
394     * @tc.require: issueNumber
395     */
396    it('KVManagerCloseKVStoreCallbackParaErrorTest', 0, async function (done) {
397        console.info('KVManagerCloseKVStoreCallbackParaErrorTest');
398        try {
399            await kvManager.getKVStore(TEST_STORE_ID, options, async function (err, store) {
400                console.info('KVManagerCloseKVStoreCallbackParaErrorTest getKVStore success');
401                kvStore = store;
402                try {
403                    await kvManager.closeKVStore(TEST_BUNDLE_NAME, function () {
404                        expect(null).assertFail();
405                        done();
406                    });
407                } catch (e) {
408                    console.error('KVManagerCloseKVStoreCallbackParaErrorTest closeKVStore e ' + `, error code is ${e.code}, message is ${e.message}`);
409                    expect(e.code == 401).assertTrue();
410                    done();
411                }
412            });
413        } catch (ee) {
414            console.error('KVManagerCloseKVStoreCallbackParaErrorTest getKVStore ee ' + `, error code is ${ee.code}, message is ${ee.message}`);
415            expect(null).assertFail();
416            done();
417        }
418    })
419
420    /**
421     * @tc.name KVManagerCloseKVStoreCallbackSucTest
422     * @tc.desc Test Js Api KVManager.CloseKVStore() successfully
423     * @tc.type: FUNC
424     * @tc.require: issueNumber
425     */
426    it('KVManagerCloseKVStoreCallbackSucTest', 0, async function (done) {
427        console.info('KVManagerCloseKVStoreCallbackSucTest');
428        try {
429            await kvManager.getKVStore(TEST_STORE_ID, options, async function (error, store) {
430                expect((error == undefined) && (store != null)).assertTrue();
431                console.info('KVManagerCloseKVStoreCallbackSucTest getKVStore success');
432                try {
433                    await kvManager.closeKVStore(TEST_BUNDLE_NAME, TEST_STORE_ID, function (err) {
434                        expect(err == undefined).assertTrue();
435                        done();
436                    });
437                } catch (e) {
438                    console.error('KVManagerCloseKVStoreCallbackSucTest closeKVStore e ' + `, error code is ${e.code}, message is ${e.message}`);
439                    expect(null).assertFail();
440                    done();
441                }
442            });
443        } catch (ee) {
444            console.error('KVManagerCloseKVStoreCallbackSucTest getKVStore ee ' + `, error code is ${ee.code}, message is ${ee.message}`);
445            expect(null).assertFail();
446            done();
447        }
448    })
449
450    /**
451     * @tc.name KVManagerCloseKVStoreCallbackCloseInvalidArgsTest
452     * @tc.desc Test Js Api KVManager.CloseKVStore() with invalid args
453     * @tc.type: FUNC
454     * @tc.require: issueNumber
455     */
456    it('KVManagerCloseKVStoreCallbackCloseTwiceFailTest', 0, async function (done) {
457        console.info('KVManagerCloseKVStoreCallbackCloseTwiceFailTest');
458        try {
459            await kvManager.getKVStore(TEST_STORE_ID, options, async function (error, store) {
460                expect((error == undefined) && (store != null)).assertTrue();
461            });
462            await kvManager.closeKVStore(TEST_BUNDLE_NAME, function () {
463                expect(null).assertFail();
464            });
465        } catch (e) {
466            console.error('KVManagerCloseKVStoreCallbackCloseTwiceFailTest closeKVStore twice e ' + `, error code is ${e.code}, message is ${e.message}`);
467            expect(e.code == 401).assertTrue();
468        }
469        done();
470    })
471
472    /**
473     * @tc.name KVManagerDeleteKVStoreCallbackSucTest
474     * @tc.desc Test Js Api KVManager.DeleteKVStore() successfully
475     * @tc.type: FUNC
476     * @tc.require: issueNumber
477     */
478    it('KVManagerDeleteKVStoreCallbackSucTest', 0, async function (done) {
479        console.info('KVManagerDeleteKVStoreCallbackSucTest');
480        try {
481            await kvManager.getKVStore(TEST_STORE_ID, options, async function (error, store) {
482                expect((error == undefined) && (store != null)).assertTrue();
483                await kvManager.deleteKVStore(TEST_BUNDLE_NAME, TEST_STORE_ID, function (err) {
484                    console.info('KVManagerDeleteKVStoreCallbackSucTest deleteKVStore success');
485                    expect(err == undefined).assertTrue();
486                    done();
487                });
488            });
489        } catch (e) {
490            console.error('KVManagerDeleteKVStoreCallbackSucTest e ' + `, error code is ${e.code}, message is ${e.message}`);
491            expect(null).assertFail();
492            done();
493        }
494    })
495
496    /**
497     * @tc.name KVManagerDeleteKVStoreCallbackParaErrorTest
498     * @tc.desc Test Js Api KVManager.DeleteKVStore() with parameter error
499     * @tc.type: FUNC
500     * @tc.require: issueNumber
501     */
502    it('KVManagerDeleteKVStoreCallbackParaErrorTest', 0, async function (done) {
503        console.info('KVManagerDeleteKVStoreCallbackParaErrorTest');
504        try {
505            await kvManager.getKVStore(TEST_STORE_ID, options, async function (error, store) {
506                expect((error == undefined) && (store != null)).assertTrue();
507                console.info('KVManagerDeleteKVStoreCallbackParaErrorTest getKVStore success');
508                try {
509                    await kvManager.deleteKVStore(TEST_BUNDLE_NAME, function () {
510                        expect(null).assertFail();
511                        done();
512                    });
513                } catch (e) {
514                    console.error('KVManagerDeleteKVStoreCallbackParaErrorTest deleteKVStore e ' + `, error code is ${e.code}, message is ${e.message}`);
515                    expect(e.code == 401).assertTrue();
516                    done();
517                }
518            });
519        } catch (ee) {
520            console.error('KVManagerDeleteKVStoreCallbackParaErrorTest getKVStore ee ' + `, error code is ${ee.code}, message is ${ee.message}`);
521            expect(null).assertFail();
522            done();
523        }
524    })
525
526    /**
527     * @tc.name KVManagerDeleteKVStoreCallbackNotGetTest
528     * @tc.desc Test Js Api KVManager.DeleteKVStore() without get kvstore
529     * @tc.type: FUNC
530     * @tc.require: issueNumber
531     */
532    it('KVManagerDeleteKVStoreCallbackNotGetTest', 0, async function (done) {
533        console.info('KVManagerDeleteKVStoreCallbackNotGetTest');
534        try {
535            await kvManager.deleteKVStore(TEST_BUNDLE_NAME, TEST_STORE_ID, function (err) {
536                if (err == undefined) {
537                    console.info('KVManagerDeleteKVStoreCallbackNotGetTest deleteKVStore success');
538                    expect(null).assertFail();
539                } else {
540                    console.info('KVManagerDeleteKVStoreCallbackNotGetTest deleteKVStore fail');
541                    expect(err.code == 15100004).assertTrue();
542                }
543                done();
544            });
545        } catch (e) {
546            console.error('KVManagerDeleteKVStoreCallbackNotGetTest e ' + `, error code is ${e.code}, message is ${e.message}`);
547            done();
548        }
549    })
550
551    /**
552     * @tc.name KVManagerGetAllKVStoreIdCallbackSucTest
553     * @tc.desc Test Js Api KVManager.GetAllKVStoreId() success
554     * @tc.type: FUNC
555     * @tc.require: issueNumber
556     */
557    it('KVManagerGetAllKVStoreIdCallbackSucTest', 0, async function (done) {
558        console.info('KVManagerGetAllKVStoreIdCallbackEqual0Test');
559        try {
560            kvManager.getAllKVStoreId(TEST_BUNDLE_NAME, function (err, data) {
561                expect(data.length == 0).assertTrue();
562                done();
563            });
564        } catch (e) {
565            console.error('KVManagerGetAllKVStoreIdCallbackEqual0Test e ' + `, error code is ${e.code}, message is ${e.message}`);
566            expect(null).assertFail();
567            done();
568        }
569    })
570
571    /**
572     * @tc.name KVManagerGetAllKVStoreIdCallbackInvalidArgsTest
573     * @tc.desc Test Js Api KVManager.GetAllKVStoreId() with invalid args
574     * @tc.type: FUNC
575     * @tc.require: issueNumber
576     */
577    it('KVManagerGetAllKVStoreIdCallbackInvalidArgsTest', 0, async function (done) {
578        console.info('KVManagerGetAllKVStoreIdCallbackInvalidArgsTest');
579        try {
580            await kvManager.getAllKVStoreId(function (err, storeIds) {
581                expect(null).assertFail();
582            });
583        } catch (e) {
584            console.error('KVManagerGetAllKVStoreIdCallbackInvalidArgsTest e ' + `, error code is ${e.code}, message is ${e.message}`);
585            expect(e.code == 401).assertTrue();
586        }
587        done();
588    })
589
590    /**
591     * @tc.name KVStorePutCallbackTest
592     * @tc.desc Test Js Api KVStore.Put()
593     * @tc.type: FUNC
594     * @tc.require: issueNumber
595     */
596    it('KVStorePutCallbackTest', 0, async function (done) {
597        console.info('KVStorePutCallbackTest');
598        try {
599            await kvManager.getKVStore(TEST_STORE_ID, options, async function (err, store) {
600                console.info('KVStorePutCallbackTest getKVStore success');
601                kvStore = store;
602                await kvStore.put(STORE_KEY, STORE_VALUE, function (err) {
603                    expect(true).assertTrue();
604                    done();
605                });
606            });
607
608        } catch (e) {
609            console.error('KVStorePutCallbackTest callback e ' + `, error code is ${e.code}, message is ${e.message}`);
610            expect(null).assertFail();
611            done();
612        }
613    })
614})
615