Skip to content

Commit

Permalink
Merge branch 'surrealdb:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
ElecTwix authored Aug 9, 2023
2 parents 4427062 + bbf7fdf commit 2785c13
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,24 @@ func TestSurrealDBSuite(t *testing.T) {
SurrealDBSuite.wsImplementations = make(map[string]websocket.WebSocket)

// Without options
SurrealDBSuite.wsImplementations["gorilla"] = gorilla.Create()
logData, err := createLogData(t)
require.NoError(t, err)
SurrealDBSuite.wsImplementations["gorilla"] = gorilla.Create().Logger(logData)

// With options
buff := bytes.NewBuffer([]byte{})
logData, err := logger.New().FromBuffer(buff).Make()
logData, err = createLogData(t)
require.NoError(t, err)
SurrealDBSuite.wsImplementations["gorilla_opt"] = gorilla.Create().SetTimeOut(time.Minute).SetCompression(true).Logger(logData)

RunWsMap(t, SurrealDBSuite)
}

func createLogData(t *testing.T) (*logger.LogData, error) {
t.Helper()
buff := bytes.NewBuffer([]byte{})
return logger.New().FromBuffer(buff).Make()
}

func RunWsMap(t *testing.T, s *SurrealDBTestSuite) {
for wsName := range s.wsImplementations {
// Run the test suite
Expand Down Expand Up @@ -85,7 +92,9 @@ func (s *SurrealDBTestSuite) openConnection() *surrealdb.DB {
if url == "" {
url = "ws://localhost:8000/rpc"
}
ws, err := s.wsImplementations[s.name].Connect(url)
impl := s.wsImplementations[s.name]
require.NotNil(s.T(), impl)
ws, err := impl.Connect(url)
s.Require().NoError(err)
db, err := surrealdb.New(url, ws)
s.Require().NoError(err)
Expand Down

0 comments on commit 2785c13

Please sign in to comment.