Skip to content

Commit

Permalink
tests(BUX-320): use test bux
Browse files Browse the repository at this point in the history
  • Loading branch information
arkadiuszos4chain committed Nov 28, 2023
1 parent ee2e88f commit f9daf76
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 2 deletions.
30 changes: 30 additions & 0 deletions actions/admin/force_sync.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package admin

import (
"net/http"

"github.com/julienschmidt/httprouter"
apirouter "github.com/mrz1836/go-api-router"
)

// destinationsCount will count all destinations filtered by metadata
// Count destinations filtering by metadata godoc
// @Summary Count destinations
// @Description Count destinations
// @Tags Admin
// @Produce json
// @Param metadata query string false "Metadata filter"
// @Param conditions query string false "Conditions filter"
// @Success 200
// @Router /v1/admin/destinations/count [post]
// @Security bux-auth-xpub
func (a *Action) forceSync(w http.ResponseWriter, req *http.Request, _ httprouter.Params) {
err := a.Services.Bux.ForceSync(req.Context())
if err != nil {
apirouter.ReturnResponse(w, req, http.StatusExpectationFailed, err.Error())
return
}

// Return response
apirouter.ReturnResponse(w, req, http.StatusOK, 1)
}
15 changes: 15 additions & 0 deletions actions/admin/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,19 @@ func RegisterRoutes(router *apirouter.Router, appConfig *config.AppConfig, servi
router.HTTPRouter.POST("/"+config.CurrentMajorVersion+"/admin/utxos/count", action.Request(router, require.Wrap(action.utxosCount)))
router.HTTPRouter.POST("/"+config.CurrentMajorVersion+"/admin/xpubs/search", action.Request(router, require.Wrap(action.xpubsSearch)))
router.HTTPRouter.POST("/"+config.CurrentMajorVersion+"/admin/xpubs/count", action.Request(router, require.Wrap(action.xpubsCount)))

// TODO: remove after tests
router.HTTPRouter.GET("/"+config.CurrentMajorVersion+"/admin/force_sync", action.Request(router, require.Wrap(action.forceSync)))
}

// RegisterRoutes register all the package specific routes

Check failure on line 49 in actions/admin/routes.go

View workflow job for this annotation

GitHub Actions / test (1.19.x, ubuntu-latest)

exported: comment on exported function RegisterTestRoutes should be of the form "RegisterTestRoutes ..." (revive)
func RegisterTestRoutes(router *apirouter.Router, appConfig *config.AppConfig, services *config.AppServices) {
// Use the authentication middleware wrapper - this will only check for a valid admin
a, require := actions.NewStack(appConfig, services)

// Load the actions and set the services
action := &Action{actions.Action{AppConfig: a.AppConfig, Services: a.Services}}

// TODO: remove after tests
router.HTTPRouter.GET("/"+config.CurrentMajorVersion+"/admin/force_sync", action.Request(router, require.Wrap(action.forceSync)))
}
4 changes: 2 additions & 2 deletions go.mod

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

6 changes: 6 additions & 0 deletions go.sum

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

2 changes: 2 additions & 0 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ func (s *Server) Handlers() *nrhttprouter.Router {
utxos.RegisterRoutes(s.Router, s.AppConfig, s.Services)
xpubs.RegisterRoutes(s.Router, s.AppConfig, s.Services)

admin.RegisterTestRoutes(s.Router, s.AppConfig, s.Services)

// Load GraphQL
if s.AppConfig.GraphQL.Enabled {
graphql.RegisterRoutes(s.Router, s.AppConfig, s.Services)
Expand Down

0 comments on commit f9daf76

Please sign in to comment.