Initial cloud-services repo - gateway service + pkg modules
This commit is contained in:
74
pkg/cache/fileids_test.go
vendored
Normal file
74
pkg/cache/fileids_test.go
vendored
Normal file
@@ -0,0 +1,74 @@
|
||||
package cache_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"fiskerinc.com/modules/cache"
|
||||
"fiskerinc.com/modules/common"
|
||||
"fiskerinc.com/modules/db"
|
||||
"fiskerinc.com/modules/db/queries"
|
||||
"fiskerinc.com/modules/db/queries/mocks"
|
||||
"fiskerinc.com/modules/redis"
|
||||
)
|
||||
|
||||
func TestRetrieveFileEncryptionParams(t *testing.T) {
|
||||
key := "b7f74938c9402dc2"
|
||||
c := NewMockRedisConn()
|
||||
q := mocks.MockFileKeys{
|
||||
GetResponse: &common.FileKey{},
|
||||
}
|
||||
|
||||
_, err := cache.RetrieveFileEncryptionParams(c, &q, []string{key})
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkRetrieveFileEncryptionParams(b *testing.B) {
|
||||
c := redis.NewClient()
|
||||
q := queries.FileKeys{}
|
||||
|
||||
for n := 0; n < b.N; n++ {
|
||||
_, err := cache.RetrieveFileEncryptionParams(c, &q, []string{"b7f74938c9402dc2"})
|
||||
if err != nil {
|
||||
b.Error(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func NewMockRedisConn() *MockRedisConn {
|
||||
mock := &MockRedisConn{}
|
||||
mock.SetConn(redis.GetMockPool().Get())
|
||||
return mock
|
||||
}
|
||||
|
||||
type MockRedisConn struct {
|
||||
redis.Connection
|
||||
}
|
||||
|
||||
func (m *MockRedisConn) GetCache(id string, dest interface{}, expire int) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *MockRedisConn) SetCache(id string, data interface{}, expire int) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *MockRedisConn) GetValuesMulti(ids []string, data interface{}) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *MockRedisConn) SetMulti(ids []string, data []interface{}) error {
|
||||
return nil
|
||||
}
|
||||
func TestRetrieveFileEncryptionParamsIntegration(t *testing.T) {
|
||||
t.Skip()
|
||||
c := redis.NewClient()
|
||||
q := queries.FileKeys{}
|
||||
q.GetClient().GetConn().AddQueryHook(db.SQLLogger{})
|
||||
|
||||
_, err := cache.RetrieveFileEncryptionParams(c, &q, []string{"bd2c7a6cc94042cb", "83165a80c940e8b3"})
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user