Skip to content

Commit

Permalink
refactor unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
micbar committed Mar 28, 2022
1 parent 0119a1d commit 691c589
Showing 1 changed file with 19 additions and 26 deletions.
45 changes: 19 additions & 26 deletions graph/pkg/service/v0/graph_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"io"
"net/http"
"net/http/httptest"
"time"

gateway "github.com/cs3org/go-cs3apis/cs3/gateway/v1beta1"
provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
Expand Down Expand Up @@ -229,32 +230,24 @@ var _ = Describe("Graph", func() {
Expect(rr.Code).To(Equal(http.StatusOK))

body, _ := io.ReadAll(rr.Body)
Expect(body).To(MatchJSON(`
{
"value":[
{
"driveAlias":"mountpoint/new-folder",
"driveType":"mountpoint",
"id":"aID!differentID",
"name":"New Folder",
"root":{
"eTag":"101112131415",
"id":"aID!differentID",
"remoteItem":{
"eTag":"123456789",
"folder":{},
"id":"ownerStorageID!opaqueID",
"lastModifiedDateTime":"2022-03-26T21:46:46+01:00",
"name":"New Folder",
"size":1234,
"webDavUrl":"https://localhost:9200/dav/spaces/ownerStorageID!opaqueID"
},
"webDavUrl":"https://localhost:9200/dav/spaces/aID!differentID"
}
}
]
}
`))

var response map[string][]libregraph.Drive
err := json.Unmarshal(body, &response)
Expect(err).ToNot(HaveOccurred())
Expect(*response["value"][0].DriveAlias).To(Equal("mountpoint/new-folder"))
Expect(*response["value"][0].DriveType).To(Equal("mountpoint"))
Expect(*response["value"][0].Id).To(Equal("aID!differentID"))
Expect(*response["value"][0].Name).To(Equal("New Folder"))
Expect(*response["value"][0].Root.WebDavUrl).To(Equal("https://localhost:9200/dav/spaces/aID!differentID"))
Expect(*response["value"][0].Root.ETag).To(Equal("101112131415"))
Expect(*response["value"][0].Root.Id).To(Equal("aID!differentID"))
Expect(*response["value"][0].Root.RemoteItem.ETag).To(Equal("123456789"))
Expect(*response["value"][0].Root.RemoteItem.Id).To(Equal("ownerStorageID!opaqueID"))
Expect(*response["value"][0].Root.RemoteItem.LastModifiedDateTime).To(Equal(time.Unix(1648327606, 0)))
Expect(*response["value"][0].Root.RemoteItem.Folder).To(Equal(libregraph.Folder{}))
Expect(*response["value"][0].Root.RemoteItem.Name).To(Equal("New Folder"))
Expect(*response["value"][0].Root.RemoteItem.Size).To(Equal(int64(1234)))
Expect(*response["value"][0].Root.RemoteItem.WebDavUrl).To(Equal("https://localhost:9200/dav/spaces/ownerStorageID!opaqueID"))
})
It("can not list spaces with wrong sort parameter", func() {
gatewayClient.On("ListStorageSpaces", mock.Anything, mock.Anything).Return(&provider.ListStorageSpacesResponse{
Expand Down

0 comments on commit 691c589

Please sign in to comment.