auth
auth/session_test.go
Implement a session store in postgres. Write the postgres implementation of our sessionStore type. Write the SQL statements to initialize the database for us. Include the postgres implementation of our sessionStore type in our sessionStore tests when the appropriate environment variable is passed.
1.1 --- a/session_test.go Tue Mar 24 21:50:42 2015 -0400 1.2 +++ b/session_test.go Mon Apr 06 07:58:10 2015 -0400 1.3 @@ -1,12 +1,23 @@ 1.4 package auth 1.5 1.6 import ( 1.7 + "os" 1.8 "testing" 1.9 "time" 1.10 1.11 "code.secondbit.org/uuid.hg" 1.12 ) 1.13 1.14 +func init() { 1.15 + if os.Getenv("PG_TEST_DB") != "" { 1.16 + p, err := NewPostgres(os.Getenv("PG_TEST_DB")) 1.17 + if err != nil { 1.18 + panic(err) 1.19 + } 1.20 + sessionStores = append(sessionStores, &p) 1.21 + } 1.22 +} 1.23 + 1.24 var sessionStores = []sessionStore{NewMemstore()} 1.25 1.26 func compareSessions(session1, session2 Session) (success bool, field string, val1, val2 interface{}) {