mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-23 14:50:24 +00:00
e46099a504
Signed-off-by: Huamin Chen <hchen@redhat.com>
45 lines
683 B
Go
45 lines
683 B
Go
// +build appengine
|
|
|
|
package memcache
|
|
|
|
import (
|
|
"bytes"
|
|
"testing"
|
|
|
|
"appengine/aetest"
|
|
)
|
|
|
|
func TestAppEngine(t *testing.T) {
|
|
ctx, err := aetest.NewContext(nil)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
defer ctx.Close()
|
|
|
|
cache := New(ctx)
|
|
|
|
key := "testKey"
|
|
_, ok := cache.Get(key)
|
|
if ok {
|
|
t.Fatal("retrieved key before adding it")
|
|
}
|
|
|
|
val := []byte("some bytes")
|
|
cache.Set(key, val)
|
|
|
|
retVal, ok := cache.Get(key)
|
|
if !ok {
|
|
t.Fatal("could not retrieve an element we just added")
|
|
}
|
|
if !bytes.Equal(retVal, val) {
|
|
t.Fatal("retrieved a different value than what we put in")
|
|
}
|
|
|
|
cache.Delete(key)
|
|
|
|
_, ok = cache.Get(key)
|
|
if ok {
|
|
t.Fatal("deleted key still present")
|
|
}
|
|
}
|