...

Source file src/github.com/gin-contrib/sessions/postgres/postgres_test.go

Documentation: github.com/gin-contrib/sessions/postgres

     1  package postgres
     2  
     3  import (
     4  	"database/sql"
     5  	"github.com/gin-contrib/sessions"
     6  	"github.com/gin-contrib/sessions/tester"
     7  	"testing"
     8  )
     9  
    10  const postgresTestServer = "postgres://testuser:testpw@localhost:5432/testdb?sslmode=disable"
    11  
    12  var newStore = func(_ *testing.T) sessions.Store {
    13  	db, err := sql.Open("postgres", postgresTestServer)
    14  	if err != nil {
    15  		panic(err)
    16  	}
    17  
    18  	store, err := NewStore(db, []byte("secret"))
    19  	if err != nil {
    20  		panic(err)
    21  	}
    22  
    23  	return store
    24  }
    25  
    26  func TestPostgres_SessionGetSet(t *testing.T) {
    27  	tester.GetSet(t, newStore)
    28  }
    29  
    30  func TestPostgres_SessionDeleteKey(t *testing.T) {
    31  	tester.DeleteKey(t, newStore)
    32  }
    33  
    34  func TestPostgres_SessionFlashes(t *testing.T) {
    35  	tester.Flashes(t, newStore)
    36  }
    37  
    38  func TestPostgres_SessionClear(t *testing.T) {
    39  	tester.Clear(t, newStore)
    40  }
    41  
    42  func TestPostgres_SessionOptions(t *testing.T) {
    43  	tester.Options(t, newStore)
    44  }
    45  
    46  func TestPostgres_SessionMany(t *testing.T) {
    47  	tester.Many(t, newStore)
    48  }
    49  

View as plain text