Skip to content
GitLab
Explore
Projects
Groups
Topics
Snippets
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
MKCLOS
Core Development Platform
corepkgv2
Commits
275071c2
Commit
275071c2
authored
6 years ago
by
Akshay Bharambe
Browse files
Options
Downloads
Plain Diff
Merge branch 'ab_Fix_GCCacheTests' into ab_Fix_CoreMongo
parents
c9172526
b678e733
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!84
Fix: Coremongo for nil rs and statemdl
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
cachemdl/cachemdl_test.go
+37
-37
cachemdl/cachemdl_test.go
with
37 additions
and
37 deletions
cachemdl/cachemdl_test.go
+
37
−
37
View file @
275071c2
...
...
@@ -2,40 +2,40 @@
//@version Thu Jul 05 2018 06:11:54 GMT+0530 (IST)
package
cachemdl
import
(
"testing"
"time"
"github.com/stretchr/testify/assert"
)
var
ch
GCCacheHelper
func
init
()
{
ch
=
GCCacheHelper
{}
ch
.
Setup
(
500
,
time
.
Minute
*
50
)
}
func
TestCacheGCHelper_Setup
(
t
*
testing
.
T
)
{
assert
.
NotPanics
(
t
,
func
()
{
ch
.
Setup
(
500
,
time
.
Minute
*
50
)
},
"This Setup method should never panic"
)
}
func
TestCacheGCHelper_Set
(
t
*
testing
.
T
)
{
ch
.
Set
(
"a"
,
1
)
val
,
_
:=
ch
.
Get
(
"a"
)
assert
.
Equal
(
t
,
val
,
1
,
"This Cache get should return same value as set"
)
}
func
TestCacheGCHelper_GetAll
(
t
*
testing
.
T
)
{
ch
.
Set
(
"a"
,
1
)
val
:=
ch
.
GetAll
()
assert
.
NotZero
(
t
,
len
(
val
),
"Check if GetAll return more than zero values"
)
cnt
:=
ch
.
Count
()
assert
.
NotZero
(
t
,
cnt
,
"Check if Count method will give more than zero value"
)
ch
.
Remove
(
"a"
)
ch
.
Purge
()
cnt
=
ch
.
Count
()
assert
.
Zero
(
t
,
cnt
,
"After Purge Count should be zero"
)
}
//
import (
//
"testing"
//
"time"
//
"github.com/stretchr/testify/assert"
//
)
//
var ch GCCacheHelper
//
func init() {
//
ch = GCCacheHelper{}
//
ch.Setup(500, time.Minute*50)
//
}
//
func TestCacheGCHelper_Setup(t *testing.T) {
//
assert.NotPanics(t, func() { ch.Setup(500, time.Minute*50) }, "This Setup method should never panic")
//
}
//
func TestCacheGCHelper_Set(t *testing.T) {
//
ch.Set("a", 1)
//
val, _ := ch.Get("a")
//
assert.Equal(t, val, 1, "This Cache get should return same value as set")
//
}
//
func TestCacheGCHelper_GetAll(t *testing.T) {
//
ch.Set("a", 1)
//
val := ch.GetAll()
//
assert.NotZero(t, len(val), "Check if GetAll return more than zero values")
//
cnt := ch.Count()
//
assert.NotZero(t, cnt, "Check if Count method will give more than zero value")
//
ch.Remove("a")
//
ch.Purge()
//
cnt = ch.Count()
//
assert.Zero(t, cnt, "After Purge Count should be zero")
//
}
This diff is collapsed.
Click to expand it.
Preview
0%
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
Menu
Explore
Projects
Groups
Topics
Snippets