mirror of
https://github.com/gofiber/storage.git
synced 2025-09-27 04:46:08 +08:00
Fix failing test
This commit is contained in:
2
.github/workflows/test-coherence.yml
vendored
2
.github/workflows/test-coherence.yml
vendored
@@ -24,7 +24,7 @@ jobs:
|
||||
uses: actions/checkout@v4
|
||||
- name: Startup Coherence
|
||||
run: |
|
||||
docker run -d -p 1408:1408 -p 30000:30000 ghcr.io/oracle/coherence-ce:22.06.5
|
||||
docker run -d -p 1408:1408 -p 30000:30000 ghcr.io/oracle/coherence-ce:23.09.2
|
||||
sleep 30
|
||||
- name: Install Go
|
||||
uses: actions/setup-go@v5
|
||||
|
@@ -166,7 +166,7 @@ func (s *Storage) Delete(key string) error {
|
||||
}
|
||||
|
||||
func (s *Storage) Reset() error {
|
||||
return s.namedCache.Clear(s.ctx)
|
||||
return s.namedCache.Truncate(s.ctx)
|
||||
}
|
||||
|
||||
func (s *Storage) Close() error {
|
||||
|
@@ -4,6 +4,7 @@ package coherence
|
||||
* Copyright © 2023, 2024 Oracle and/or its affiliates.
|
||||
*/
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/stretchr/testify/require"
|
||||
"os"
|
||||
"testing"
|
||||
@@ -22,7 +23,8 @@ var testStore *Storage
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
testStore, _ = New(Config{
|
||||
Reset: true,
|
||||
Reset: true,
|
||||
NearCacheTimeout: time.Duration(4) * time.Second,
|
||||
})
|
||||
|
||||
code := m.Run()
|
||||
@@ -34,9 +36,8 @@ func TestMain(m *testing.M) {
|
||||
// newTestStore returns a new Coherence Store and ensures it is reset.
|
||||
func newTestStore(t testing.TB, config ...Config) (*Storage, error) {
|
||||
t.Helper()
|
||||
var err error
|
||||
|
||||
testStore, err = New(config...)
|
||||
testStore, err := New(config...)
|
||||
require.NoError(t, err)
|
||||
|
||||
err = testStore.Reset()
|
||||
@@ -98,7 +99,7 @@ func Test_Coherence_Set_With_Expiry(t *testing.T) {
|
||||
// set with an expiry of 5 seconds
|
||||
err := testStore.Set(key1, value1, time.Duration(5)*time.Second)
|
||||
require.NoError(t, err)
|
||||
time.Sleep(time.Duration(10) * time.Second)
|
||||
time.Sleep(time.Duration(6) * time.Second)
|
||||
|
||||
val, err = testStore.Get(key1)
|
||||
require.NoError(t, err)
|
||||
@@ -137,6 +138,7 @@ func Test_Coherence_Reset(t *testing.T) {
|
||||
// check the keys have expired
|
||||
val, err = testStore.Get(key1)
|
||||
require.NoError(t, err)
|
||||
fmt.Println("val=", string(val))
|
||||
require.True(t, len(val) == 0)
|
||||
|
||||
val, err = testStore.Get(key2)
|
||||
|
Reference in New Issue
Block a user