mirror of
https://github.com/gofiber/storage.git
synced 2025-10-04 08:16:36 +08:00
🩹 update tests
This commit is contained in:
@@ -137,10 +137,11 @@ func (s *Storage) Get(key string) ([]byte, error) {
|
||||
return data, nil
|
||||
}
|
||||
|
||||
// Set key with value
|
||||
// Set key with value
|
||||
func (s *Storage) Set(key string, val []byte, exp time.Duration) error {
|
||||
// Ain't Nobody Got Time For That
|
||||
if len(val) <= 0 {
|
||||
if len(key) <= 0 || len(val) <= 0 {
|
||||
return nil
|
||||
}
|
||||
var expSeconds int64
|
||||
@@ -154,6 +155,10 @@ func (s *Storage) Set(key string, val []byte, exp time.Duration) error {
|
||||
|
||||
// Delete entry by key
|
||||
func (s *Storage) Delete(key string) error {
|
||||
// Ain't Nobody Got Time For That
|
||||
if len(key) <= 0 {
|
||||
return nil
|
||||
}
|
||||
_, err := s.db.Exec(s.sqlDelete, key)
|
||||
return err
|
||||
}
|
||||
|
@@ -99,7 +99,7 @@ func Test_Postgres_Delete(t *testing.T) {
|
||||
utils.AssertEqual(t, true, len(result) == 0)
|
||||
}
|
||||
|
||||
func Test_Postgres_Clear(t *testing.T) {
|
||||
func Test_Postgres_Reset(t *testing.T) {
|
||||
var (
|
||||
val = []byte("doe")
|
||||
)
|
||||
@@ -123,6 +123,5 @@ func Test_Postgres_Clear(t *testing.T) {
|
||||
}
|
||||
|
||||
func Test_Postgres_Close(t *testing.T) {
|
||||
err := testStore.Close()
|
||||
utils.AssertEqual(t, nil, err)
|
||||
utils.AssertEqual(t, nil, testStore.Close())
|
||||
}
|
||||
|
Reference in New Issue
Block a user