mirror of
https://github.com/SourceFellows/gobuch.git
synced 2025-07-19 22:52:52 +02:00
initial import
This commit is contained in:
@ -0,0 +1,16 @@
|
||||
package rest
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"golang.source-fellows.com/samples/applicationx"
|
||||
)
|
||||
|
||||
func Handler(us applicationx.UserService) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
us.CreateUser(&applicationx.User{})
|
||||
fmt.Fprintf(w, "Hello World! %s", time.Now())
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package rest
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
|
||||
"github.com/golang/mock/gomock"
|
||||
"golang.source-fellows.com/samples/applicationx/mocks"
|
||||
)
|
||||
|
||||
func TestHandler(t *testing.T) {
|
||||
|
||||
ctrl := gomock.NewController(t)
|
||||
defer ctrl.Finish()
|
||||
|
||||
userService := mocks.NewMockUserService(ctrl)
|
||||
|
||||
handlerFunc := Handler(userService)
|
||||
|
||||
w := httptest.NewRecorder()
|
||||
r, _ := http.NewRequest("GET", "/egal", nil)
|
||||
|
||||
//wird der Service überhaupt aufgerufen?
|
||||
userService.EXPECT().CreateUser(gomock.Any()).MinTimes(1)
|
||||
|
||||
handlerFunc(w, r)
|
||||
|
||||
}
|
Reference in New Issue
Block a user