Exemplo n.º 1
0
func TestStorageReInitError(t *testing.T) {
	nsg, err := store.NewStorage(store.WithDatabaseInit(nil))
	assert.Nil(t, nsg)
	if assert.Error(t, err) {
		assert.Contains(t, err.Error(), "dbr.SessionRunner is nil\n")
	}
}
Exemplo n.º 2
0
func main() {
	a := newApp()
	defer a.close() // @todo check signal and close gracefully

	ctx := store.WithContextMustService(
		scope.Option{Website: scope.MockID(1)}, // run website ID 1, see database table, like Mage::run('code','store')
		store.MustNewStorage(store.WithDatabaseInit(a.dbc.NewSession())),
	)

	ctx = config.WithContextGetter(ctx, a.config)

	router := ctxrouter.New(ctx)
	a.routeLogin(router)
	a.setupStoreRoutes(router)

	router.Handle("GET", "/error", func(ctx context.Context, w http.ResponseWriter, r *http.Request) error {
		return store.ErrContextServiceNotFound
	})

	println("Starting server @ ", ServerAddress)

	log.Fatal("ListenAndServe", "err", http.ListenAndServe(ServerAddress, router))

}