Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
client
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
elixxir
client
Commits
403f7f41
Commit
403f7f41
authored
Aug 4, 2020
by
Jake Taylor
Browse files
Options
Downloads
Patches
Plain Diff
add getLastMessage to session
parent
dc3e4159
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
globals/version_vars.go
+8
-2
8 additions, 2 deletions
globals/version_vars.go
storage/session.go
+17
-0
17 additions, 0 deletions
storage/session.go
storage/session_test.go
+41
-0
41 additions, 0 deletions
storage/session_test.go
with
66 additions
and
2 deletions
globals/version_vars.go
+
8
−
2
View file @
403f7f41
////////////////////////////////////////////////////////////////////////////////
// Copyright © 2020 Privategrity Corporation /
// /
// All rights reserved. /
////////////////////////////////////////////////////////////////////////////////
// Code generated by go generate; DO NOT EDIT.
// This file was generated by robots at
// 2020-08-0
3
1
9
:0
0:29.952394
-0
4
00
E
DT m=+0.0
18956226
// 2020-08-0
4
1
4
:0
3:41.019893
-0
7
00
P
DT m=+0.0
29153253
package
globals
const
GITVERSION
=
`
f944e22 fix tests surrounding new client storage objec
t`
const
GITVERSION
=
`
dc3e415 re-enable session smoke tes
t`
const
SEMVER
=
"1.4.0"
const
DEPENDENCIES
=
`module gitlab.com/elixxir/client
...
...
This diff is collapsed.
Click to expand it.
storage/session.go
+
17
−
0
View file @
403f7f41
////////////////////////////////////////////////////////////////////////////////
// Copyright © 2020 Privategrity Corporation /
// /
// All rights reserved. /
////////////////////////////////////////////////////////////////////////////////
package
storage
import
"gitlab.com/elixxir/ekv"
...
...
@@ -25,3 +31,14 @@ func (s *Session) Get(key string) (*VersionedObject, error) {
func
(
s
*
Session
)
Set
(
key
string
,
object
*
VersionedObject
)
error
{
return
s
.
kv
.
Set
(
key
,
object
)
}
// Obtain the LastMessageID from the Session
func
(
s
*
Session
)
GetLastMessageId
()
(
string
,
error
)
{
v
,
err
:=
s
.
kv
.
Get
(
"LastMessageID"
)
return
string
(
v
.
Data
),
err
}
// Set the LastMessageID in the Session
func
(
s
*
Session
)
SetLastMessageId
(
object
*
VersionedObject
)
error
{
return
s
.
kv
.
Set
(
"LastMessageID"
,
object
)
}
This diff is collapsed.
Click to expand it.
storage/session_test.go
+
41
−
0
View file @
403f7f41
////////////////////////////////////////////////////////////////////////////////
// Copyright © 2020 Privategrity Corporation /
// /
// All rights reserved. /
////////////////////////////////////////////////////////////////////////////////
package
storage
import
(
...
...
@@ -42,5 +48,40 @@ func TestSession_Smoke(t *testing.T) {
if
bytes
.
Compare
(
o
.
Data
,
[]
byte
(
"test"
))
!=
0
{
t
.
Errorf
(
"Failed to get data"
)
}
}
// Happy path for getting/setting LastMessageID
func
TestSession_GetSetLastMessageId
(
t
*
testing
.
T
)
{
testId
:=
"testLastMessageId"
err
:=
os
.
RemoveAll
(
".session_testdir"
)
if
err
!=
nil
{
t
.
Errorf
(
err
.
Error
())
}
s
,
err
:=
Init
(
".session_testdir"
,
"test"
)
if
err
!=
nil
{
t
.
Log
(
s
)
t
.
Errorf
(
"failed to init: %+v"
,
err
)
}
ts
,
err
:=
time
.
Now
()
.
MarshalText
()
if
err
!=
nil
{
t
.
Errorf
(
"Failed to martial time for object"
)
}
err
=
s
.
SetLastMessageId
(
&
VersionedObject
{
Version
:
0
,
Timestamp
:
ts
,
Data
:
[]
byte
(
testId
),
})
if
err
!=
nil
{
t
.
Errorf
(
"Failed to set LastMessageId: %+v"
,
err
)
}
o
,
err
:=
s
.
GetLastMessageId
()
if
err
!=
nil
{
t
.
Errorf
(
"Failed to get LastMessageId"
)
}
if
testId
!=
o
{
t
.
Errorf
(
"Failed to get LastMessageID, Got %s Expected %s"
,
o
,
testId
)
}
}
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