Skip to content

Commit

Permalink
Merge pull request #1255 from threefoldtech/development_proxy_fixTests
Browse files Browse the repository at this point in the history
fix proxy tests
  • Loading branch information
Omarabdul3ziz authored Nov 13, 2024
2 parents fd37a4f + 5c909e9 commit ea8357b
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 4 deletions.
8 changes: 8 additions & 0 deletions grid-proxy/docs/docs.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions grid-proxy/docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -1571,6 +1571,14 @@
"TwinConsumption"
],
"summary": "Show a report for user consumption",
"parameters": [
{
"type": "integer",
"description": "twin id",
"name": "twin_id",
"in": "path"
}
],
"responses": {
"200": {
"description": "OK",
Expand Down
5 changes: 5 additions & 0 deletions grid-proxy/docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1512,6 +1512,11 @@ paths:
consumes:
- application/json
description: Get a report of user spent for last hour and for lifetime
parameters:
- description: twin id
in: path
name: twin_id
type: integer
produces:
- application/json
responses:
Expand Down
1 change: 1 addition & 0 deletions grid-proxy/internal/explorer/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,7 @@ func (a *App) listTwins(r *http.Request) (interface{}, mw.Response) {
// @Summary Show a report for user consumption
// @Description Get a report of user spent for last hour and for lifetime
// @Tags TwinConsumption
// @Param twin_id path int yes "twin id"
// @Accept json
// @Produce json
// @Success 200 {object} []types.TwinConsumption
Expand Down
4 changes: 2 additions & 2 deletions grid-proxy/tests/queries/mock_client/contracts.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,8 +273,8 @@ func (g *GridProxyMockClient) Contract(ctx context.Context, contractID uint32) (
Type: "rent",
Details: types.RentContractDetails{
NodeID: uint(rentContract.NodeID),
FarmId: g.data.Nodes[nodeContract.NodeID].FarmID,
FarmName: g.data.Farms[g.data.Nodes[nodeContract.NodeID].FarmID].Name,
FarmId: g.data.Nodes[rentContract.NodeID].FarmID,
FarmName: g.data.Farms[g.data.Nodes[rentContract.NodeID].FarmID].Name,
},
}, err
}
Expand Down
3 changes: 1 addition & 2 deletions grid-proxy/tests/queries/mock_client/nodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,8 @@ func (g *GridProxyMockClient) Nodes(ctx context.Context, filter types.NodeFilter
return res[i].NodeID < res[j].NodeID
})

if filter.AvailableFor != nil {
if filter.AvailableFor != nil || filter.RentableOrRentedBy != nil {
sort.Slice(res, func(i, j int) bool {

return g.data.NodeRentContractID[uint64(res[i].NodeID)] != 0
})
}
Expand Down

0 comments on commit ea8357b

Please sign in to comment.