Skip to content

Commit

Permalink
fix: data asset upload fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Siddharth9890 committed Nov 4, 2024
1 parent 91ddf33 commit bedfc63
Show file tree
Hide file tree
Showing 8 changed files with 232 additions and 179 deletions.
10 changes: 6 additions & 4 deletions client/accounts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,9 @@ func TestAccountsImpl(t *testing.T) {
}
httpmock.RegisterResponder("PATCH", gateway.GetMyAccount, responder)

var pic = "test"
updateDetails := gateway.AccountUpdateRequest{
ProfilePicture: "test",
ProfilePicture: &pic,
}
myAccount, err := accountImpl.UpdateMe(updateDetails)

Expand All @@ -148,8 +149,9 @@ func TestAccountsImpl(t *testing.T) {
errorResponse := `{"error": "Failed to update account"}`
httpmock.RegisterResponder("PATCH", gateway.GetMyAccount, httpmock.NewStringResponder(400, errorResponse))

var pic = "test"
updateDetails := gateway.AccountUpdateRequest{
ProfilePicture: "test",
ProfilePicture: &pic,
}
myAccount, err := accountImpl.UpdateMe(updateDetails)

Expand All @@ -163,9 +165,9 @@ func TestAccountsImpl(t *testing.T) {
httpmock.RegisterResponder("PATCH", gateway.GetMyAccount, func(req *http.Request) (*http.Response, error) {
return nil, errors.New("client-side error")
})

var pic = "test"
updateDetails := gateway.AccountUpdateRequest{
ProfilePicture: "test",
ProfilePicture: &pic,
}
myAccount, err := accountImpl.UpdateMe(updateDetails)

Expand Down
14 changes: 8 additions & 6 deletions client/data_asset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,9 @@ func TestDataAssetSuite(t *testing.T) {
return resp, nil
}
httpmock.RegisterResponder("PUT", "/data-assets/1", responder)

var name = "New Asset"
input := gateway.UpdateDataAssetRequest{
Name: "New Asset",
Name: &name,
}
result, err := dataAssetImpl.UpdateAsset("1", input)

Expand All @@ -202,8 +202,9 @@ func TestDataAssetSuite(t *testing.T) {
httpmock.RegisterResponder("PUT", gateway.UpdateDataAssetByID,
httpmock.NewStringResponder(500, fixture))

var name = "New Asset"
input := gateway.UpdateDataAssetRequest{
Name: "New Asset",
Name: &name,
}
asset, err := dataAssetImpl.UpdateAsset("1", input)

Expand All @@ -217,8 +218,9 @@ func TestDataAssetSuite(t *testing.T) {
httpmock.RegisterResponder("PUT", gateway.UpdateDataAssetByID,
httpmock.NewErrorResponder(errors.New("http request error")))

var name = "New Asset"
input := gateway.UpdateDataAssetRequest{
Name: "New Asset",
Name: &name,
}
asset, err := dataAssetImpl.UpdateAsset("1", input)

Expand Down Expand Up @@ -337,8 +339,8 @@ func TestDataAssetSuite(t *testing.T) {

message, err := dataAssetImpl.DeleteAsset(1)

assert.Error(t, err)
assert.Empty(t, message)
assert.Error(t, err)
assert.Empty(t, message)
})

t.Run("TestUploadFileSuccess", func(t *testing.T) {
Expand Down
11 changes: 8 additions & 3 deletions client/data_model_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,8 +312,9 @@ func TestDataModelSuite(t *testing.T) {
httpmock.RegisterResponder("PUT", gateway.UpdateDataModel, responder)

id := int64(2)
var title = "UpdatedModel"
dataModelInput := gateway.DataModelUpdateRequest{
Title: "UpdatedModel",
Title: &title,
}
result, err := dataModelImpl.Update(id, dataModelInput)

Expand All @@ -328,8 +329,10 @@ func TestDataModelSuite(t *testing.T) {
httpmock.RegisterResponder("PUT", gateway.UpdateDataModel, responder)

id := int64(2)
var title = "UpdatedModel"

dataModelInput := gateway.DataModelUpdateRequest{
Title: "UpdatedModel",
Title: &title,
}
result, err := dataModelImpl.Update(id, dataModelInput)

Expand All @@ -345,8 +348,10 @@ func TestDataModelSuite(t *testing.T) {
})

id := int64(2)
var title = "UpdatedModel"

dataModelInput := gateway.DataModelUpdateRequest{
Title: "UpdatedModel",
Title: &title,
}
result, err := dataModelImpl.Update(id, dataModelInput)

Expand Down
41 changes: 23 additions & 18 deletions client/routes.go
Original file line number Diff line number Diff line change
@@ -1,33 +1,38 @@
package client

const (
AddWallet = "/accounts/me/wallets"
GetReceivedDataAssets = "/data-assets/received"
GetDataModels = "/data-models"
CreateDataModel = "/data-models"
AcceptComputeRequest = "/compute-requests/{id}/accept"
DownloadDataAssetByID = "/data-assets/{id}/download"
GetDataAssetsByDataModelID = "/data-models/{id}/data-assets"
CreateAccount = "/accounts"
RemoveWallet = "/accounts/me/wallets/{address}"
RefreshToken = "/auth/refresh-token"
GetComputeRequests = "/compute-requests/me"
AuthenticateAccount = "/auth"
CreateANewDataAsset = "/data-assets"
GetComputeRequestsReceived = "/compute-requests/received"
GetDataAssetByID = "/data-assets/{id}"
UpdateDataAssetByID = "/data-assets/{id}"
DeleteDataAssetByID = "/data-assets/{id}"
AssignACLItemsToDataAsset = "/data-assets/{id}/acl"
UpdateACLItemsToDataAsset = "/data-assets/{id}/acl"
GetDataModelsByUser = "/data-models/me"
GetDataAssetsByDataModelID = "/data-models/{id}/data-assets"
CreateAccount = "/accounts"
RemoveWallet = "/accounts/me/wallets/{address}"
GenerateSignMessage = "/auth/message"
Compute = "/compute-requests/{id}"
DeleteAssignedRoleByACL = "/data-assets/{id}/acl/delete"
DownloadDataAssetByID = "/data-assets/{id}/download"
ShareDataAssetByID = "/data-assets/{id}/share"
GetComputeRequest = "/compute-requests/{id}"
GetCreatedDataAssets = "/data-assets/created"
GetDataModelByID = "/data-models/{id}"
UpdateDataModel = "/data-models/{id}"
GetMyAccount = "/accounts/me"
UpdateAccount = "/accounts/me"
GetAccount = "/accounts/{did}"
RefreshToken = "/auth/refresh-token"
GetCreatedDataAssets = "/data-assets/created"
AddWallet = "/accounts/me/wallets"
DeleteAssignedRoleByACL = "/data-assets/{id}/acl/delete"
GetAllDataAssetsThatTheAuthenticatedUserHasAccessTo = "/data-assets/me"
GetReceivedDataAssets = "/data-assets/received"
ShareDataAssetByID = "/data-assets/{id}/share"
GetAccount = "/accounts/{did}"
GenerateSignMessage = "/auth/message"
CreateComputeRequest = "/compute-requests"
CreateComputingProcess = "/compute-requests/{id}/start"
CreateANewDataAsset = "/data-assets"
AssignACLItemsToDataAsset = "/data-assets/{id}/acl"
UpdateACLItemsToDataAsset = "/data-assets/{id}/acl"
GetDataModels = "/data-models"
CreateDataModel = "/data-models"
)

Loading

0 comments on commit bedfc63

Please sign in to comment.