Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Fabian Vitt
good2go
Commits
e7f8c220
Commit
e7f8c220
authored
Jun 04, 2020
by
Can Maihofer
Browse files
good stuff
parent
f7074cfb
Pipeline
#1835
failed with stages
in 55 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
api/rest/subrouters/room_router.go
View file @
e7f8c220
...
...
@@ -101,6 +101,7 @@ func deleteRoom(res http.ResponseWriter, req *http.Request) {
// AttachRouter initialize Router
func
(
a
roomRouter
)
AttachRouter
(
router
*
mux
.
Router
)
{
//todo addd single room route
r
:=
router
.
PathPrefix
(
"/rooms"
)
.
Subrouter
()
.
StrictSlash
(
true
)
// CREATE
...
...
database/mongo/repositories/building_repository.go
View file @
e7f8c220
...
...
@@ -69,7 +69,7 @@ func (repo *Repository) CreateBuilding(building *model.Building) (*model.Buildin
return
&
result
,
nil
}
func
(
repo
*
Repository
)
UpdateBuilding
(
building
*
model
.
Building
)
(
*
mongo
.
UpdateResult
,
error
)
{
func
(
repo
*
Repository
)
UpdateBuilding
(
building
*
model
.
Building
)
(
*
mongo
.
UpdateResult
,
error
)
{
ctx
,
cancel
:=
utils
.
CreateTimeoutCTX
(
time
.
Second
*
10
)
defer
cancel
()
res
,
err
:=
repo
.
Col
.
ReplaceOne
(
ctx
,
bson
.
M
{
"_id"
:
&
building
.
ID
},
&
building
)
...
...
database/mongo/repositories/room_repository.go
View file @
e7f8c220
...
...
@@ -190,3 +190,20 @@ func (repo *Repository) DeleteRoom(roomID string) (room *model.Room, err error)
return
repo
.
findByID
(
roomID
)
}
func
(
repo
*
Repository
)
GetAllRooms
()
[]
*
model
.
Room
{
ctx
,
cancel
:=
utils
.
CreateTimeoutCTX
(
5
*
time
.
Second
)
defer
cancel
()
cursor
,
err
:=
repo
.
Col
.
Find
(
ctx
,
bson
.
M
{})
if
err
!=
nil
{
log
.
Fatal
(
"[MONGODB] roomRepository"
,
err
)
}
var
rooms
[]
*
model
.
Room
if
err
=
cursor
.
All
(
ctx
,
&
rooms
);
err
!=
nil
{
log
.
Fatal
(
err
)
}
return
rooms
}
internal/services/building_service_test.go
View file @
e7f8c220
package
services
import
(
"git.coco.study/fvitt/good2go/internal/model"
"testing"
"git.coco.study/fvitt/good2go/internal/model"
)
func
TestBuildingService_CreateRoom
(
t
*
testing
.
T
)
{
...
...
@@ -48,9 +49,9 @@ func TestBuildingService_GetRoom(t *testing.T) {
}
}
func
TestBuildingService_GetRooms
(
t
*
testing
.
T
)
{
func
TestBuildingService_Get
All
Rooms
(
t
*
testing
.
T
)
{
BuildDefBuilding
()
roomsMap
:=
BuildingService
.
GetRooms
()
roomsMap
:=
BuildingService
.
Get
All
Rooms
()
if
len
(
roomsMap
)
<=
0
{
t
.
Error
(
"did not get any room, expected one"
)
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment