Mentions légales du service
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
c-service
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
concordant
Software
c-service
Commits
dac14fbb
Commit
dac14fbb
authored
4 years ago
by
Ludovic Le Frioux
Browse files
Options
Downloads
Patches
Plain Diff
Update CRDTWrapper tests
parent
014114bc
No related branches found
No related tags found
2 merge requests
!48
Release v1.1.4
,
!29
Resolve "Update C-CRDTLib to v0.0.7"
Pipeline
#193221
passed
4 years ago
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/CRDTs/PouchDBCRDTs.test.ts
+19
-19
19 additions, 19 deletions
test/CRDTs/PouchDBCRDTs.test.ts
with
19 additions
and
19 deletions
test/CRDTs/PouchDBCRDTs.test.ts
+
19
−
19
View file @
dac14fbb
...
@@ -94,15 +94,15 @@ describe("Basic usage", () => {
...
@@ -94,15 +94,15 @@ describe("Basic usage", () => {
TEST_KEY
=
uuid
();
TEST_KEY
=
uuid
();
const
defaultObject
=
CRDTWrapper
.
wrap
(
new
crdtlib
.
crdt
.
PNCounter
());
const
defaultObject
=
CRDTWrapper
.
wrap
(
new
crdtlib
.
crdt
.
PNCounter
());
return
connection2
return
connection2
.
get
<
CRDTWrapper
<
any
>
>
(
TEST_KEY
,
()
=>
defaultObject
)
.
get
<
CRDTWrapper
>
(
TEST_KEY
,
()
=>
defaultObject
)
.
then
(()
=>
connection2
.
get
<
CRDTWrapper
<
any
>
>
(
TEST_KEY
))
.
then
(()
=>
connection2
.
get
<
CRDTWrapper
>
(
TEST_KEY
))
.
then
((
obj
:
Document
<
CRDTWrapper
<
any
>
>
)
=>
{
.
then
((
obj
:
Document
<
CRDTWrapper
>
)
=>
{
const
newCRDT
=
CRDTWrapper
.
unwrap
(
obj
.
current
());
const
newCRDT
=
CRDTWrapper
.
unwrap
(
obj
.
current
());
newCRDT
.
increment
(
42
,
environment1
.
tick
());
newCRDT
.
increment
(
42
,
environment1
.
tick
());
return
obj
.
update
(
CRDTWrapper
.
wrap
(
newCRDT
)).
save
();
return
obj
.
update
(
CRDTWrapper
.
wrap
(
newCRDT
)).
save
();
})
})
.
then
(()
=>
connection2
.
get
<
CRDTWrapper
<
any
>
>
(
TEST_KEY
))
.
then
(()
=>
connection2
.
get
<
CRDTWrapper
>
(
TEST_KEY
))
.
then
((
obj
:
Document
<
CRDTWrapper
<
any
>
>
)
=>
{
.
then
((
obj
:
Document
<
CRDTWrapper
>
)
=>
{
const
newCRDT
=
CRDTWrapper
.
unwrap
(
obj
.
current
());
const
newCRDT
=
CRDTWrapper
.
unwrap
(
obj
.
current
());
expect
(
newCRDT
.
get
()).
toBe
(
42
);
expect
(
newCRDT
.
get
()).
toBe
(
42
);
})
})
...
@@ -118,15 +118,15 @@ describe("Basic usage", () => {
...
@@ -118,15 +118,15 @@ describe("Basic usage", () => {
const
client2DefaultObjectWrapped
=
CRDTWrapper
.
wrap
(
const
client2DefaultObjectWrapped
=
CRDTWrapper
.
wrap
(
new
crdtlib
.
crdt
.
PNCounter
()
new
crdtlib
.
crdt
.
PNCounter
()
);
);
let
remoteObj
:
Document
<
CRDTWrapper
<
any
>
>
;
let
remoteObj
:
Document
<
CRDTWrapper
>
;
let
onlyAfter
=
false
;
let
onlyAfter
=
false
;
// hooks are handled by client2
// hooks are handled by client2
// need to create hooks for different connections to set different clientIds.
// need to create hooks for different connections to set different clientIds.
const
hooks
:
DatabaseHooks
=
{
const
hooks
:
DatabaseHooks
=
{
conflictHandler
:
(
conflictHandler
:
(
obj
:
Document
<
CRDTWrapper
<
any
>
>
,
obj
:
Document
<
CRDTWrapper
>
,
objs
:
Array
<
Document
<
CRDTWrapper
<
any
>
>>
objs
:
Array
<
Document
<
CRDTWrapper
>>
)
=>
{
)
=>
{
if
(
!
onlyAfter
)
{
if
(
!
onlyAfter
)
{
fail
(
"
Unexpected conflict trigger
"
);
fail
(
"
Unexpected conflict trigger
"
);
...
@@ -146,7 +146,7 @@ describe("Basic usage", () => {
...
@@ -146,7 +146,7 @@ describe("Basic usage", () => {
connection2
.
registerHooks
(
hooks
);
connection2
.
registerHooks
(
hooks
);
const
sub
=
connection1
.
subscribe
<
CRDTWrapper
<
any
>
>
(
TEST_KEY
,
{
const
sub
=
connection1
.
subscribe
<
CRDTWrapper
>
(
TEST_KEY
,
{
change
:
(
key
,
newObj
)
=>
{
change
:
(
key
,
newObj
)
=>
{
connection1
.
cancel
(
sub
);
connection1
.
cancel
(
sub
);
onlyAfter
=
true
;
onlyAfter
=
true
;
...
@@ -163,7 +163,7 @@ describe("Basic usage", () => {
...
@@ -163,7 +163,7 @@ describe("Basic usage", () => {
.
catch
((
err
)
=>
fail
(
err
));
.
catch
((
err
)
=>
fail
(
err
));
})
})
.
then
(()
=>
promiseDelay
(
null
,
200
))
.
then
(()
=>
promiseDelay
(
null
,
200
))
.
then
(()
=>
connection2
.
get
<
CRDTWrapper
<
any
>
>
(
TEST_KEY
))
.
then
(()
=>
connection2
.
get
<
CRDTWrapper
>
(
TEST_KEY
))
.
then
((
obj
)
=>
{
.
then
((
obj
)
=>
{
const
unwrapped
=
CRDTWrapper
.
unwrap
(
obj
.
current
());
const
unwrapped
=
CRDTWrapper
.
unwrap
(
obj
.
current
());
expect
(
unwrapped
.
get
()).
toBe
(
42
);
expect
(
unwrapped
.
get
()).
toBe
(
42
);
...
@@ -173,8 +173,8 @@ describe("Basic usage", () => {
...
@@ -173,8 +173,8 @@ describe("Basic usage", () => {
});
});
return
connection2
return
connection2
.
get
<
CRDTWrapper
<
any
>
>
(
TEST_KEY
,
()
=>
client2DefaultObjectWrapped
)
.
get
<
CRDTWrapper
>
(
TEST_KEY
,
()
=>
client2DefaultObjectWrapped
)
.
then
((
obj
:
Document
<
CRDTWrapper
<
any
>
>
)
=>
(
remoteObj
=
obj
))
.
then
((
obj
:
Document
<
CRDTWrapper
>
)
=>
(
remoteObj
=
obj
))
.
catch
((
error
)
=>
fail
(
error
));
.
catch
((
error
)
=>
fail
(
error
));
});
});
});
});
...
@@ -245,13 +245,13 @@ describe("Test offline support with CRDTs", () => {
...
@@ -245,13 +245,13 @@ describe("Test offline support with CRDTs", () => {
const
client2DefaultObjectWrapped
=
CRDTWrapper
.
wrap
(
const
client2DefaultObjectWrapped
=
CRDTWrapper
.
wrap
(
new
crdtlib
.
crdt
.
PNCounter
()
new
crdtlib
.
crdt
.
PNCounter
()
);
);
let
remoteObj
:
Document
<
CRDTWrapper
<
any
>
>
;
let
remoteObj
:
Document
<
CRDTWrapper
>
;
let
onlyAfter
=
false
;
let
onlyAfter
=
false
;
const
hooks
:
DatabaseHooks
=
{
const
hooks
:
DatabaseHooks
=
{
conflictHandler
:
(
conflictHandler
:
(
obj
:
Document
<
CRDTWrapper
<
any
>
>
,
obj
:
Document
<
CRDTWrapper
>
,
objs
:
Array
<
Document
<
CRDTWrapper
<
any
>
>>
objs
:
Array
<
Document
<
CRDTWrapper
>>
)
=>
{
)
=>
{
if
(
!
onlyAfter
)
{
if
(
!
onlyAfter
)
{
fail
(
"
Unexpected conflict trigger
"
);
fail
(
"
Unexpected conflict trigger
"
);
...
@@ -270,7 +270,7 @@ describe("Test offline support with CRDTs", () => {
...
@@ -270,7 +270,7 @@ describe("Test offline support with CRDTs", () => {
connection2
.
registerHooks
(
hooks
);
connection2
.
registerHooks
(
hooks
);
const
sub
=
connection1
.
subscribe
<
CRDTWrapper
<
any
>
>
(
TEST_KEY
,
{
const
sub
=
connection1
.
subscribe
<
CRDTWrapper
>
(
TEST_KEY
,
{
change
:
(
key
,
newObj
)
=>
{
change
:
(
key
,
newObj
)
=>
{
connection1
.
cancel
(
sub
);
connection1
.
cancel
(
sub
);
onlyAfter
=
true
;
onlyAfter
=
true
;
...
@@ -288,7 +288,7 @@ describe("Test offline support with CRDTs", () => {
...
@@ -288,7 +288,7 @@ describe("Test offline support with CRDTs", () => {
})
})
.
then
(()
=>
promiseDelay
(
null
,
200
))
.
then
(()
=>
promiseDelay
(
null
,
200
))
// .then(() => connection2.goOnline())
// .then(() => connection2.goOnline())
.
then
(()
=>
connection2
.
get
<
CRDTWrapper
<
any
>
>
(
TEST_KEY
))
.
then
(()
=>
connection2
.
get
<
CRDTWrapper
>
(
TEST_KEY
))
.
then
((
obj
)
=>
{
.
then
((
obj
)
=>
{
const
unwrapped
=
CRDTWrapper
.
unwrap
(
obj
.
current
());
const
unwrapped
=
CRDTWrapper
.
unwrap
(
obj
.
current
());
expect
(
unwrapped
.
get
()).
toBe
(
42
);
expect
(
unwrapped
.
get
()).
toBe
(
42
);
...
@@ -298,8 +298,8 @@ describe("Test offline support with CRDTs", () => {
...
@@ -298,8 +298,8 @@ describe("Test offline support with CRDTs", () => {
});
});
return
connection2
return
connection2
.
get
<
CRDTWrapper
<
any
>
>
(
TEST_KEY
,
()
=>
client2DefaultObjectWrapped
)
.
get
<
CRDTWrapper
>
(
TEST_KEY
,
()
=>
client2DefaultObjectWrapped
)
.
then
((
obj
:
Document
<
CRDTWrapper
<
any
>
>
)
=>
(
remoteObj
=
obj
))
.
then
((
obj
:
Document
<
CRDTWrapper
>
)
=>
(
remoteObj
=
obj
))
.
then
(()
=>
connection2
.
goOffline
())
.
then
(()
=>
connection2
.
goOffline
())
.
catch
((
error
)
=>
fail
(
error
));
.
catch
((
error
)
=>
fail
(
error
));
});
});
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment