func TestPutDate(t *testing.T) { resp := server_mock.NewHttpResponseWriterMock() db := booking_database_sqlite.New("/tmp/booking_test.db", false) userService := booking_user_service.New(booking_user_storage.New(db)) handler := createHandler(db, userService) req, err := createRequest("/date", userService) if err = AssertThat(err, NilValue()); err != nil { t.Fatal(err) } req.Body = io_mock.NewReadCloserString("{}") req.Method = "PUT" handler.ServeHTTP(resp, req) if err = AssertThat(resp.Status(), Is(200)); err != nil { t.Fatal(err) } }
func TestVerifyLoginHandlerFound(t *testing.T) { resp := server_mock.NewHttpResponseWriterMock() db := booking_database_sqlite.New("/tmp/booking_test.db", false) userService := booking_user_service.New(booking_user_storage.New(db)) _, err := userService.Create(&booking_user.User{Login: "******", Password: "******"}) if err = AssertThat(err, NilValue()); err != nil { t.Fatal(err) } handler := createHandler(db, userService) req, err := createRequest("/authentication/verifyLogin", userService) if err = AssertThat(err, NilValue()); err != nil { t.Fatal(err) } req.Body = io_mock.NewReadCloserString(`{"login":"******","password":"******"}`) req.Method = "POST" handler.ServeHTTP(resp, req) if err = AssertThat(resp.Status(), Is(200)); err != nil { t.Fatal(err) } }