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
ece3b054
Commit
ece3b054
authored
Mar 28, 2022
by
Josh Brooks
Browse files
Options
Downloads
Patches
Plain Diff
Write tests for new method
parent
4209c155
No related branches found
No related tags found
3 merge requests
!233
Modify restore to call user-defined bindings callback. Add Sent requests to...
,
!231
Revert "Update store to print changes to the partners list"
,
!191
Properly repopulate UD store after backup
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
storage/ud/facts_test.go
+67
-0
67 additions, 0 deletions
storage/ud/facts_test.go
with
67 additions
and
0 deletions
storage/ud/facts_test.go
+
67
−
0
View file @
ece3b054
...
...
@@ -16,6 +16,7 @@ import (
"testing"
)
// Smoke test.
func
TestNewStore
(
t
*
testing
.
T
)
{
kv
:=
versioned
.
NewKV
(
make
(
ekv
.
Memstore
))
...
...
@@ -27,6 +28,67 @@ func TestNewStore(t *testing.T) {
}
// Unit test
func
TestStore_RestoreFromBackUp
(
t
*
testing
.
T
)
{
kv
:=
versioned
.
NewKV
(
make
(
ekv
.
Memstore
))
s
,
err
:=
NewStore
(
kv
)
if
err
!=
nil
{
t
.
Errorf
(
"NewStore() produced an error: %v"
,
err
)
}
expected
:=
fact
.
Fact
{
Fact
:
"josh"
,
T
:
fact
.
Username
,
}
fl
:=
fact
.
FactList
{
expected
}
err
=
s
.
RestoreFromBackUp
(
fl
)
if
err
!=
nil
{
t
.
Fatalf
(
"RestoreFromBackup err: %v"
,
err
)
}
_
,
exists
:=
s
.
confirmedFacts
[
expected
]
if
!
exists
{
t
.
Fatalf
(
"Fact %s does not exist in map"
,
expected
)
}
}
// Error case.
func
TestStore_RestoreFromBackUp_StatefulStore
(
t
*
testing
.
T
)
{
kv
:=
versioned
.
NewKV
(
make
(
ekv
.
Memstore
))
s
,
err
:=
NewStore
(
kv
)
if
err
!=
nil
{
t
.
Errorf
(
"NewStore() produced an error: %v"
,
err
)
}
confirmId
:=
"confirm"
expected
:=
fact
.
Fact
{
Fact
:
"josh"
,
T
:
fact
.
Username
,
}
err
=
s
.
StoreUnconfirmedFact
(
confirmId
,
expected
)
if
err
!=
nil
{
t
.
Fatalf
(
"StoreUnconfirmedFact error: %v"
,
err
)
}
// Expected error: should error when restoring on
// a stateful store.
fl
:=
fact
.
FactList
{
expected
}
err
=
s
.
RestoreFromBackUp
(
fl
)
if
err
==
nil
{
t
.
Fatalf
(
"RestoreFromBackup err: %v"
,
err
)
}
}
// Unit test.
func
TestStore_ConfirmFact
(
t
*
testing
.
T
)
{
kv
:=
versioned
.
NewKV
(
make
(
ekv
.
Memstore
))
...
...
@@ -93,6 +155,7 @@ func TestStore_StoreUnconfirmedFact(t *testing.T) {
}
}
// Unit test.
func
TestStore_DeleteFact
(
t
*
testing
.
T
)
{
kv
:=
versioned
.
NewKV
(
make
(
ekv
.
Memstore
))
...
...
@@ -125,6 +188,7 @@ func TestStore_DeleteFact(t *testing.T) {
}
// Unit test.
func
TestStore_BackUpMissingFacts
(
t
*
testing
.
T
)
{
kv
:=
versioned
.
NewKV
(
make
(
ekv
.
Memstore
))
...
...
@@ -160,6 +224,7 @@ func TestStore_BackUpMissingFacts(t *testing.T) {
}
// Error case.
func
TestStore_BackUpMissingFacts_DuplicateFactType
(
t
*
testing
.
T
)
{
kv
:=
versioned
.
NewKV
(
make
(
ekv
.
Memstore
))
...
...
@@ -197,6 +262,7 @@ func TestStore_BackUpMissingFacts_DuplicateFactType(t *testing.T) {
}
// Unit test.
func
TestStore_GetFacts
(
t
*
testing
.
T
)
{
kv
:=
versioned
.
NewKV
(
make
(
ekv
.
Memstore
))
...
...
@@ -246,6 +312,7 @@ func TestStore_GetFacts(t *testing.T) {
}
}
// Unit test.
func
TestStore_GetFactStrings
(
t
*
testing
.
T
)
{
kv
:=
versioned
.
NewKV
(
make
(
ekv
.
Memstore
))
...
...
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