Implement MVC

This commit is contained in:
Sung Won Cho 2021-01-03 17:51:57 +11:00
commit cd5d094c25
146 changed files with 13596 additions and 2328 deletions

View file

@ -18,31 +18,31 @@
package api
import (
"net/http/httptest"
"testing"
"github.com/dnote/dnote/pkg/server/app"
"github.com/pkg/errors"
)
// MustNewServer is a test utility function to initialize a new server
// with the given app paratmers
func MustNewServer(t *testing.T, appParams *app.App) *httptest.Server {
api := NewTestAPI(appParams)
r, err := NewRouter(&api)
if err != nil {
t.Fatal(errors.Wrap(err, "initializing server"))
}
server := httptest.NewServer(r)
return server
}
// NewTestAPI returns a new API for test
func NewTestAPI(appParams *app.App) API {
a := app.NewTest(appParams)
return API{App: &a}
}
// import (
// "net/http/httptest"
// "testing"
//
// "github.com/dnote/dnote/pkg/server/app"
// "github.com/pkg/errors"
// )
//
// // MustNewServer is a test utility function to initialize a new server
// // with the given app paratmers
// func MustNewServer(t *testing.T, appParams *app.App) *httptest.Server {
// api := NewTestAPI(appParams)
// r, err := NewRouter(&api)
// if err != nil {
// t.Fatal(errors.Wrap(err, "initializing server"))
// }
//
// server := httptest.NewServer(r)
//
// return server
// }
//
// // NewTestAPI returns a new API for test
// func NewTestAPI(appParams *app.App) API {
// a := app.NewTest(appParams)
//
// return API{App: &a}
// }