Commit 3561fa92 authored by Enrico Bollen's avatar Enrico Bollen 💬

Merge remote-tracking branch 'origin/let-us-finish-dis' into let-us-finish-dis

parents 1dac2c2a e7f8c220
Pipeline #1836 failed with stages
in 55 seconds
......@@ -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
......
......@@ -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)
......
......@@ -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
}
package services
import (
"git.coco.study/fvitt/good2go/internal/model"
"testing"
"git.coco.study/fvitt/good2go/internal/model"
)
func TestBuildingService_CreateRoom(t *testing.T) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment