Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
parvit committed Sep 17, 2024
1 parent 79d96e2 commit 75440e6
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 11 deletions.
2 changes: 1 addition & 1 deletion backend/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func Register(key string, backend QuicBackend) {
func Get(key string) (QuicBackend, bool) {
val, ok := bcRegister[key]
if !ok {
return bcRegister[bcDefaultBackend], true
return bcRegister[bcDefaultBackend], false
}
return val, ok
}
Expand Down
7 changes: 6 additions & 1 deletion service/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ package service
import (
"context"
"github.com/Project-Faster/monkey"
service "github.com/parvit/kardianos-service"
"github.com/Project-Faster/qpep/api"
"github.com/Project-Faster/qpep/shared/configuration"
"github.com/Project-Faster/qpep/workers/client"
"github.com/Project-Faster/qpep/workers/gateway"
"github.com/Project-Faster/qpep/workers/server"
service "github.com/parvit/kardianos-service"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/suite"
"os"
Expand Down Expand Up @@ -43,6 +43,11 @@ func (s *ServiceSuite) AfterTest(_, _ string) {
func (s *ServiceSuite) BeforeTest(_, _ string) {
configuration.QPepConfig = configuration.QPepConfigType{}
configuration.QPepConfig.Merge(&configuration.DefaultConfig)

// this to stop requiring admin rights to start tests
configuration.QPepConfig.General.APIPort = 9443
configuration.QPepConfig.Client.LocalListenPort = 9444
configuration.QPepConfig.Server.LocalListenPort = 9444
}

func (s *ServiceSuite) TestServiceMain_Server() {
Expand Down
4 changes: 2 additions & 2 deletions windivert/windivert_other_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func (s *WinDivertSuite) TestInitializeWinDivertEngine() {

code := InitializeWinDivertEngine(
addr, addr,
configuration.QPepConfig.GatewayAPIPort, 445,
configuration.QPepConfig.General.APIPort, 445,
4, 0)

assert.Equal(t, DIVERT_OK, code)
Expand All @@ -56,7 +56,7 @@ func (s *WinDivertSuite) TestCloseWinDivertEngine() {

code := InitializeWinDivertEngine(
addr, addr,
configuration.QPepConfig.GatewayAPIPort, 445,
configuration.QPepConfig.General.APIPort, 445,
4, 0)

assert.Equal(t, DIVERT_OK, code)
Expand Down
10 changes: 5 additions & 5 deletions windivert/windivert_windows_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ func (s *WinDivertSuite) BeforeTest(_, _ string) {
}

flags.Globals.Client = false
configuration.QPepConfig.Verbose = true
configuration.QPepConfig.ListenHost = "127.0.0.1"
configuration.QPepConfig.GatewayAPIPort = 9443
configuration.QPepConfig.General.Verbose = true
configuration.QPepConfig.Client.LocalListeningAddress = "127.0.0.1"
configuration.QPepConfig.General.APIPort = 9443
s.finished = false
s.ctx, s.cancel = context.WithCancel(context.Background())

Expand All @@ -76,7 +76,7 @@ func (s *WinDivertSuite) TestInitializeWinDivertEngine() {

code := InitializeWinDivertEngine(
addr, addr,
configuration.QPepConfig.GatewayAPIPort, 445,
configuration.QPepConfig.General.APIPort, 445,
4, itFaces[0])

assert.Equal(t, DIVERT_OK, code)
Expand All @@ -102,7 +102,7 @@ func (s *WinDivertSuite) TestCloseWinDivertEngine() {

code := InitializeWinDivertEngine(
addr, addr,
configuration.QPepConfig.GatewayAPIPort, 445,
configuration.QPepConfig.General.APIPort, 445,
4, itFaces[0])

assert.Equal(t, DIVERT_OK, code)
Expand Down
4 changes: 2 additions & 2 deletions workers/client/client_proxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,13 @@ type fakeListener struct {
}

func (l *fakeListener) AcceptTCP() (*net.TCPConn, error) {
return nil, shared.ErrFailed
return nil, errors.ErrFailed
}

var _ net.Listener = &fakeListener{}

func (l *fakeListener) Accept() (net.Conn, error) {
return nil, shared.ErrFailed
return nil, errors.ErrFailed
}
func (l *fakeListener) Addr() net.Addr {
return nil
Expand Down

0 comments on commit 75440e6

Please sign in to comment.