mirror of
https://github.com/gofiber/storage.git
synced 2025-10-09 02:20:20 +08:00
Updated test-scylladb, README and tests to use testify for Asserts
This commit is contained in:
2
.github/workflows/test-scylladb.yml
vendored
2
.github/workflows/test-scylladb.yml
vendored
@@ -18,8 +18,8 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
go-version:
|
go-version:
|
||||||
- 1.19.x
|
|
||||||
- 1.20.x
|
- 1.20.x
|
||||||
|
- 1.21.x
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Fetch Repository
|
- name: Fetch Repository
|
||||||
|
@@ -5,7 +5,7 @@ title: ScyllaDb
|
|||||||
|
|
||||||
# ScyllaDb
|
# ScyllaDb
|
||||||
|
|
||||||
A ScyllaDb storage engine for [Fiber](github.com/gofiber/fiber) using [gocql](github.com/gocql/gocql).
|
A ScyllaDb storage engine for [Fiber](github.com/gofiber/fiber) using [gocql](github.com/scylladb/gocql).
|
||||||
|
|
||||||
### Table of Contents
|
### Table of Contents
|
||||||
- [Signatures](#signatures)
|
- [Signatures](#signatures)
|
||||||
|
@@ -1,14 +1,19 @@
|
|||||||
module github.com/gofiber/storage/scylladb
|
module github.com/gofiber/storage/scylladb
|
||||||
|
|
||||||
go 1.19
|
go 1.20
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/gocql/gocql v1.6.0
|
github.com/gocql/gocql v1.6.0
|
||||||
github.com/gofiber/utils v1.1.0
|
github.com/gofiber/utils v1.1.0
|
||||||
|
github.com/stretchr/testify v1.3.0
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/golang/snappy v0.0.4 // indirect
|
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||||
|
github.com/golang/snappy v0.0.3 // indirect
|
||||||
github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed // indirect
|
github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed // indirect
|
||||||
|
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||||
gopkg.in/inf.v0 v0.9.1 // indirect
|
gopkg.in/inf.v0 v0.9.1 // indirect
|
||||||
)
|
)
|
||||||
|
|
||||||
|
replace github.com/gocql/gocql => github.com/scylladb/gocql v1.11.1
|
||||||
|
@@ -3,13 +3,14 @@ github.com/bitly/go-hostpool v0.0.0-20171023180738-a3a6125de932/go.mod h1:NOuUCS
|
|||||||
github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869 h1:DDGfHa7BWjL4YnC6+E63dPcxHo2sUxDIu8g3QgEJdRY=
|
github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869 h1:DDGfHa7BWjL4YnC6+E63dPcxHo2sUxDIu8g3QgEJdRY=
|
||||||
github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869/go.mod h1:Ekp36dRnpXw/yCqJaO+ZrUyxD+3VXMFFr56k5XYrpB4=
|
github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869/go.mod h1:Ekp36dRnpXw/yCqJaO+ZrUyxD+3VXMFFr56k5XYrpB4=
|
||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/gocql/gocql v1.6.0 h1:IdFdOTbnpbd0pDhl4REKQDM+Q0SzKXQ1Yh+YZZ8T/qU=
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
github.com/gocql/gocql v1.6.0/go.mod h1:3gM2c4D3AnkISwBxGnMMsS8Oy4y2lhbPRsH4xnJrHG8=
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/gofiber/utils v1.1.0 h1:vdEBpn7AzIUJRhe+CiTOJdUcTg4Q9RK+pEa0KPbLdrM=
|
github.com/gofiber/utils v1.1.0 h1:vdEBpn7AzIUJRhe+CiTOJdUcTg4Q9RK+pEa0KPbLdrM=
|
||||||
github.com/gofiber/utils v1.1.0/go.mod h1:poZpsnhBykfnY1Mc0KeEa6mSHrS3dV0+oBWyeQmb2e0=
|
github.com/gofiber/utils v1.1.0/go.mod h1:poZpsnhBykfnY1Mc0KeEa6mSHrS3dV0+oBWyeQmb2e0=
|
||||||
|
github.com/golang/snappy v0.0.3 h1:fHPg5GQYlCeLIPB9BZqMVR5nR9A+IM5zcgeTdjMYmLA=
|
||||||
github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
||||||
github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM=
|
github.com/google/go-cmp v0.4.0 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4=
|
||||||
github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||||
github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed h1:5upAirOpQc1Q53c0bnx2ufif5kANL7bfZWcc6VJWJd8=
|
github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed h1:5upAirOpQc1Q53c0bnx2ufif5kANL7bfZWcc6VJWJd8=
|
||||||
github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed/go.mod h1:tMWxXQ9wFIaZeTI9F+hmhFiGpFmhOHzyShyFUhRm0H4=
|
github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed/go.mod h1:tMWxXQ9wFIaZeTI9F+hmhFiGpFmhOHzyShyFUhRm0H4=
|
||||||
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
|
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
|
||||||
@@ -17,8 +18,25 @@ github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORN
|
|||||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||||
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
|
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
|
||||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||||
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
|
github.com/scylladb/gocql v1.11.1 h1:AlIPHHZf2l0Cbj8wGjfELspaGfnd4meGj9sPQnr5dn8=
|
||||||
|
github.com/scylladb/gocql v1.11.1/go.mod h1:ZLEJ0EVE5JhmtxIW2stgHq/v1P4fWap0qyyXSKyV8K0=
|
||||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
|
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
|
||||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||||
|
golang.org/x/net v0.0.0-20220526153639-5463443f8c37 h1:lUkvobShwKsOesNfWWlCS5q7fnbG1MEliIzwu886fn8=
|
||||||
|
golang.org/x/net v0.0.0-20220526153639-5463443f8c37/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
||||||
|
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||||
|
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||||
|
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
|
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc=
|
gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc=
|
||||||
gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw=
|
gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw=
|
||||||
|
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
||||||
|
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
||||||
|
sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo=
|
||||||
|
sigs.k8s.io/yaml v1.3.0/go.mod h1:GeOyir5tyXNByN85N/dRIT9es5UQNerPYEKK56eTBm8=
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
package scylladb
|
package scylladb
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/gofiber/utils"
|
"github.com/stretchr/testify/require"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
@@ -15,7 +15,7 @@ func Test_Scylla_Set(t *testing.T) {
|
|||||||
value = []byte("doe")
|
value = []byte("doe")
|
||||||
)
|
)
|
||||||
err := testStore.Set(key, value, time.Minute)
|
err := testStore.Set(key, value, time.Minute)
|
||||||
utils.AssertEqual(t, nil, err, "Failed to set the value")
|
require.NoError(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
func Test_Scylla_Set_Override(t *testing.T) {
|
func Test_Scylla_Set_Override(t *testing.T) {
|
||||||
@@ -25,10 +25,10 @@ func Test_Scylla_Set_Override(t *testing.T) {
|
|||||||
)
|
)
|
||||||
|
|
||||||
err := testStore.Set(key, val, 0)
|
err := testStore.Set(key, val, 0)
|
||||||
utils.AssertEqual(t, nil, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
err = testStore.Set(key, val, 0)
|
err = testStore.Set(key, val, 0)
|
||||||
utils.AssertEqual(t, nil, err)
|
require.NoError(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
func Test_Scylla_Get(t *testing.T) {
|
func Test_Scylla_Get(t *testing.T) {
|
||||||
@@ -38,11 +38,11 @@ func Test_Scylla_Get(t *testing.T) {
|
|||||||
)
|
)
|
||||||
|
|
||||||
err := testStore.Set(key, val, 0)
|
err := testStore.Set(key, val, 0)
|
||||||
utils.AssertEqual(t, nil, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
result, err := testStore.Get(key)
|
result, err := testStore.Get(key)
|
||||||
utils.AssertEqual(t, nil, err)
|
require.NoError(t, err)
|
||||||
utils.AssertEqual(t, val, result)
|
require.Equal(t, val, result)
|
||||||
}
|
}
|
||||||
|
|
||||||
func Test_Scylla_Set_Expiration(t *testing.T) {
|
func Test_Scylla_Set_Expiration(t *testing.T) {
|
||||||
@@ -53,7 +53,7 @@ func Test_Scylla_Set_Expiration(t *testing.T) {
|
|||||||
)
|
)
|
||||||
|
|
||||||
err := testStore.Set(key, val, exp)
|
err := testStore.Set(key, val, exp)
|
||||||
utils.AssertEqual(t, nil, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
time.Sleep(1100 * time.Millisecond)
|
time.Sleep(1100 * time.Millisecond)
|
||||||
}
|
}
|
||||||
@@ -61,8 +61,8 @@ func Test_Scylla_Set_Expiration(t *testing.T) {
|
|||||||
func Test_Scylla_Get_NotExist(t *testing.T) {
|
func Test_Scylla_Get_NotExist(t *testing.T) {
|
||||||
|
|
||||||
result, err := testStore.Get("not-exist")
|
result, err := testStore.Get("not-exist")
|
||||||
utils.AssertEqual(t, nil, err)
|
require.NoError(t, err)
|
||||||
utils.AssertEqual(t, true, len(result) == 0)
|
require.Zero(t, len(result))
|
||||||
}
|
}
|
||||||
|
|
||||||
func Test_Scylla_Delete(t *testing.T) {
|
func Test_Scylla_Delete(t *testing.T) {
|
||||||
@@ -72,14 +72,14 @@ func Test_Scylla_Delete(t *testing.T) {
|
|||||||
)
|
)
|
||||||
|
|
||||||
err := testStore.Set(key, val, 0)
|
err := testStore.Set(key, val, 0)
|
||||||
utils.AssertEqual(t, nil, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
err = testStore.Delete(key)
|
err = testStore.Delete(key)
|
||||||
utils.AssertEqual(t, nil, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
result, err := testStore.Get(key)
|
result, err := testStore.Get(key)
|
||||||
utils.AssertEqual(t, nil, err)
|
require.NoError(t, err)
|
||||||
utils.AssertEqual(t, true, len(result) == 0)
|
require.Zero(t, len(result))
|
||||||
}
|
}
|
||||||
|
|
||||||
func Test_Scylla_Reset(t *testing.T) {
|
func Test_Scylla_Reset(t *testing.T) {
|
||||||
@@ -88,27 +88,27 @@ func Test_Scylla_Reset(t *testing.T) {
|
|||||||
)
|
)
|
||||||
|
|
||||||
err := testStore.Set("john1", val, 0)
|
err := testStore.Set("john1", val, 0)
|
||||||
utils.AssertEqual(t, nil, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
err = testStore.Set("john2", val, 0)
|
err = testStore.Set("john2", val, 0)
|
||||||
utils.AssertEqual(t, nil, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
err = testStore.Reset()
|
err = testStore.Reset()
|
||||||
utils.AssertEqual(t, nil, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
result, err := testStore.Get("john1")
|
result, err := testStore.Get("john1")
|
||||||
utils.AssertEqual(t, nil, err)
|
require.NoError(t, err)
|
||||||
utils.AssertEqual(t, true, len(result) == 0)
|
require.Zero(t, len(result))
|
||||||
|
|
||||||
result, err = testStore.Get("john2")
|
result, err = testStore.Get("john2")
|
||||||
utils.AssertEqual(t, nil, err)
|
require.NoError(t, err)
|
||||||
utils.AssertEqual(t, true, len(result) == 0)
|
require.Zero(t, len(result))
|
||||||
}
|
}
|
||||||
|
|
||||||
func Test_Scylla_Close(t *testing.T) {
|
func Test_Scylla_Close(t *testing.T) {
|
||||||
utils.AssertEqual(t, nil, testStore.Close())
|
require.Nil(t, testStore.Close())
|
||||||
}
|
}
|
||||||
|
|
||||||
func Test_Scylla_Conn(t *testing.T) {
|
func Test_Scylla_Conn(t *testing.T) {
|
||||||
utils.AssertEqual(t, true, testStore.Conn() != nil)
|
require.True(t, testStore.Conn() != nil)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user