Developing lightweight computation at the DSG edge
Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
LightKone
antidote-go-client
Commits
cbe18517
Commit
cbe18517
authored
Jul 12, 2018
by
Mathias Weber
Browse files
fixes set remove operation
parent
776530da
Changes
2
Hide whitespace changes
Inline
Side-by-side
antidoteclient_test.go
View file @
cbe18517
...
...
@@ -90,6 +90,77 @@ func TestSetUpdate(t *testing.T) {
}
}
func
TestSetUpdateRemove
(
t
*
testing
.
T
)
{
client
,
err
:=
NewClient
(
Host
{
"127.0.0.1"
,
8087
})
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
defer
client
.
Close
()
tx
,
err
:=
client
.
StartTransaction
()
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
timestamp
:=
time
.
Now
()
.
Unix
()
bucketname
:=
fmt
.
Sprintf
(
"bucket%d"
,
timestamp
)
bucket
:=
Bucket
{[]
byte
(
bucketname
)}
key
:=
Key
(
"keySet"
)
err
=
bucket
.
Update
(
tx
,
SetAdd
(
key
,
[]
byte
(
"test1"
),
[]
byte
(
"value2"
),
[]
byte
(
"inset3"
)))
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
err
=
tx
.
Commit
()
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
tx
,
err
=
client
.
StartTransaction
()
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
err
=
bucket
.
Update
(
tx
,
SetRemove
(
key
,
[]
byte
(
"test1"
)))
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
err
=
tx
.
Commit
()
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
tx
,
err
=
client
.
StartTransaction
()
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
setVal
,
err
:=
bucket
.
ReadSet
(
tx
,
key
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
err
=
tx
.
Commit
()
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
if
len
(
setVal
)
!=
2
{
t
.
Fatalf
(
"Wrong size: %s"
,
setVal
)
}
for
_
,
expected
:=
range
[]
string
{
"value2"
,
"inset3"
}
{
found
:=
false
for
_
,
val
:=
range
setVal
{
if
string
(
val
)
==
expected
{
found
=
true
break
}
}
if
!
found
{
t
.
Fatalf
(
"expected value %s not found in result (%s)"
,
expected
,
setVal
)
}
}
}
func
TestMap
(
t
*
testing
.
T
)
{
client
,
err
:=
NewClient
(
Host
{
"127.0.0.1"
,
8087
})
if
err
!=
nil
{
...
...
transactions.go
View file @
cbe18517
...
...
@@ -341,7 +341,7 @@ func SetRemove(key Key, elems ...[]byte) *CRDTUpdate {
Key
:
key
,
Type
:
CRDTType_ORSET
,
Update
:
&
ApbUpdateOperation
{
Setop
:
&
ApbSetUpdate
{
Add
s
:
elems
,
Optype
:
&
optype
},
Setop
:
&
ApbSetUpdate
{
Rem
s
:
elems
,
Optype
:
&
optype
},
},
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment