mirror of
https://github.com/gofiber/storage.git
synced 2025-10-05 00:33:03 +08:00
Add unit tests for Redis connection
Implemented tests to verify Redis key management functions including set, get, and delete operations. Ensuring data integrity and operation correctness in Redis storage.
This commit is contained in:
@@ -576,3 +576,27 @@ func Benchmark_Redis_WithConnection_Get(b *testing.B) {
|
||||
|
||||
require.NoError(b, err)
|
||||
}
|
||||
|
||||
func Test_Redis_NewFromConnection(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
connection := New(Config{
|
||||
Reset: true,
|
||||
})
|
||||
|
||||
testStore := NewFromConnection(connection.Conn())
|
||||
|
||||
err := testStore.Set("foo", []byte("bar"), 0)
|
||||
require.NoError(t, err, "failed to set key in Redis storage")
|
||||
|
||||
val, err := testStore.Get("foo")
|
||||
require.NoError(t, err, "failed to get key from Redis storage")
|
||||
require.Equal(t, []byte("bar"), val, "value mismatch in Redis storage")
|
||||
|
||||
err = testStore.Delete("foo")
|
||||
require.NoError(t, err, "failed to delete key in Redis storage")
|
||||
|
||||
val, err = testStore.Get("foo")
|
||||
|
||||
require.Nil(t, val, "expected value to be nil after deletion")
|
||||
}
|
||||
|
Reference in New Issue
Block a user