initial import

This commit is contained in:
SourceFellows
2020-08-21 06:26:40 +02:00
commit e223458dd4
423 changed files with 9871 additions and 0 deletions

View File

@ -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())
}
}

View File

@ -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)
}