Skip to content

Commit

Permalink
Added integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
glothriel committed May 24, 2024
1 parent 90ec45c commit 2ad37d3
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/integration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:

- name: Install packages required for tests
shell: bash
run: cd ${{ inputs.test-directory }} && python setup.py develop
run: cd tests && python setup.py develop

- name: Run integration tests
run: py.test -v --tb=short
Expand Down
14 changes: 12 additions & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,23 @@ linters-settings:
lll:
line-length: 120

depguard:
rules:
Main:
list-mode: lax
files:
- $all
- "!$test"
deny:
- pkg: reflect
desc: Please don't use reflect package

linters:
disable-all: true
enable:
- revive
- ifshort
- staticcheck
- depguard
- gosec
- dogsled
- godox
Expand All @@ -30,11 +39,12 @@ linters:
- gofmt
- gocognit
- dupl
- depguard
- whitespace
- goconst
- unconvert

issues:
max-issues-per-linter: 0
max-same-issues: 0
exclude-use-default: false
exclude-use-default: false
3 changes: 3 additions & 0 deletions pkg/api/admin.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
// Package api contains administrative APIs used for querying and manipulation of peers and apps
package api

import (
"github.com/gin-gonic/gin"
)

// Controller contains a set of functionalities for the API
type Controller interface {
registerRoutes(r *gin.Engine)
}

// NewAdminAPI bootstraps the creation of the gin engine
func NewAdminAPI(controllers []Controller) *gin.Engine {
r := gin.Default()
for _, controller := range controllers {
Expand Down
3 changes: 2 additions & 1 deletion pkg/api/apps.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ func (ac *appsController) registerRoutes(r *gin.Engine) {
})
}

func NewAppsController(appSource hello.AppSource) *appsController {
// NewAppsController bootstraps creation of the API that allows displaying currently exposed apps
func NewAppsController(appSource hello.AppSource) Controller {
return &appsController{appSource: appSource}
}
4 changes: 2 additions & 2 deletions pkg/api/peers.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@ func (p *peerController) registerRoutes(r *gin.Engine) {
"error": err.Error(),
})
return

}
c.JSON(204, nil)
})
}

func NewWgController(peers hello.PeerStorage, wgConfig *wg.Config, watcher *wg.Watcher) *peerController {
// NewPeersController allows querying and manipulation of the connected peers
func NewPeersController(peers hello.PeerStorage, wgConfig *wg.Config, watcher *wg.Watcher) Controller {
return &peerController{
peers: peers,
wgConfig: wgConfig,
Expand Down
5 changes: 3 additions & 2 deletions pkg/cmd/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ package cmd

import (
"fmt"
"github.com/glothriel/wormhole/pkg/api"
"net/http"

"github.com/glothriel/wormhole/pkg/api"

"github.com/glothriel/wormhole/pkg/hello"
"github.com/glothriel/wormhole/pkg/k8s"
"github.com/glothriel/wormhole/pkg/listeners"
Expand Down Expand Up @@ -181,7 +182,7 @@ var listenCommand *cli.Command = &cli.Command{
go func() {
err := api.NewAdminAPI([]api.Controller{
api.NewAppsController(appSource),
api.NewWgController(peerStorage, wgConfig, watcher),
api.NewPeersController(peerStorage, wgConfig, watcher),
}).Run(":8082")
if err != nil {
logrus.Fatalf("Failed to start admin API: %v", err)
Expand Down

0 comments on commit 2ad37d3

Please sign in to comment.