package render import ( "encoding/gob" "go-udemy-web-1/internal/config" "go-udemy-web-1/internal/models" "log" "net/http" "os" "testing" "time" "github.com/alexedwards/scs/v2" ) var ( session *scs.SessionManager testApp config.AppConfig ) func TestMain(m *testing.M) { // what am I going to put in the session gob.Register(models.Reservation{}) // change this to true when in production testApp.InProduction = false session = scs.New() session.Lifetime = 24 * time.Hour session.Cookie.Persist = true session.Cookie.SameSite = http.SameSiteLaxMode session.Cookie.Secure = testApp.InProduction testApp.Session = session infoLog := log.New(os.Stdout, "INFO\t", log.Ldate|log.Ltime) testApp.InfoLog = infoLog errorLog := log.New(os.Stdout, "ERROR\t", log.Ldate|log.Ltime|log.Lshortfile) testApp.ErrorLog = errorLog app = &testApp os.Exit(m.Run()) } type myWriter struct{} func (tw *myWriter) Header() http.Header { var h http.Header return h } func (tw *myWriter) WriteHeader(i int) {} func (tw *myWriter) Write(b []byte) (int, error) { length := len(b) return length, nil }