Skip to content

Commit

Permalink
fix graph tests
Browse files Browse the repository at this point in the history
Signed-off-by: jkoberg <[email protected]>
  • Loading branch information
kobergj committed Mar 25, 2024
1 parent 979bcd7 commit 06e3574
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions services/graph/pkg/service/v0/drives.go
Original file line number Diff line number Diff line change
Expand Up @@ -424,8 +424,8 @@ func (g Graph) CreateDrive(w http.ResponseWriter, r *http.Request) {
}

space := resp.GetStorageSpace()
if driveType == _spaceTypeProject {
if err := g.applySpaceTemplate(gatewayClient, resp.GetStorageSpace().GetRoot(), r.URL.Query().Get("template")); err != nil {
if t := r.URL.Query().Get("template"); t != "" && driveType == _spaceTypeProject {
if err := g.applySpaceTemplate(r.Context(), gatewayClient, resp.GetStorageSpace().GetRoot(), t); err != nil {
logger.Error().Err(err).Msg("could not apply template to space")
errorcode.GeneralException.Render(w, r, http.StatusInternalServerError, err.Error())
return
Expand Down
7 changes: 6 additions & 1 deletion services/graph/pkg/service/v0/graph_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -764,6 +764,12 @@ var _ = Describe("Graph", func() {
Constraint: v0.Permission_CONSTRAINT_ALL,
},
}, nil)

gatewayClient.On("GetQuota", mock.Anything, mock.Anything).Return(&provider.GetQuotaResponse{
Status: status.NewOK(ctx),
TotalBytes: 500,
}, nil)

jsonBody := []byte(`{"Name": "Test Space", "DriveType": "project", "Description": "This space is for testing", "DriveAlias": "project/testspace"}`)
r := httptest.NewRequest(http.MethodPost, "/graph/v1.0/drives", bytes.NewBuffer(jsonBody)).WithContext(ctx)
rr := httptest.NewRecorder()
Expand Down Expand Up @@ -808,7 +814,6 @@ var _ = Describe("Graph", func() {
Expect(libreError.Error.Message).To(Equal("space has no root"))
Expect(libreError.Error.Code).To(Equal(errorcode.GeneralException.String()))
})
})
})

Describe("Get a single drive", func() {
Expand Down
7 changes: 1 addition & 6 deletions services/graph/pkg/service/v0/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ func cs3ReceivedShareToLibreGraphPermissions(ctx context.Context, logger *log.Lo
return permission, nil
}

func (g Graph) applySpaceTemplate(gwc gateway.GatewayAPIClient, root *storageprovider.ResourceId, template string) error {
func (g Graph) applySpaceTemplate(ctx context.Context, gwc gateway.GatewayAPIClient, root *storageprovider.ResourceId, template string) error {
var fsys fs.ReadDirFS

switch template {
Expand All @@ -465,11 +465,6 @@ func (g Graph) applySpaceTemplate(gwc gateway.GatewayAPIClient, root *storagepro
mdc := metadata.NewCS3(g.config.Reva.Address, g.config.Spaces.StorageUsersAddress)
mdc.SpaceRoot = root

ctx, err := utils.GetServiceUserContext(g.config.ServiceAccount.ServiceAccountID, gwc, g.config.ServiceAccount.ServiceAccountSecret)
if err != nil {
return err
}

opaque, err := uploadFolder(ctx, mdc, ".", "", nil, fsys)
if err != nil {
return err
Expand Down

0 comments on commit 06e3574

Please sign in to comment.