mirror of
https://github.com/dnote/dnote
synced 2026-03-18 08:19:55 +01:00
Implement MVC
This commit is contained in:
parent
172f608b66
commit
cd5d094c25
146 changed files with 13596 additions and 2328 deletions
|
|
@ -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}
|
||||
// }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue