File: suite_test.go

package info (click to toggle)
golang-github-k0swe-wsjtx-go 4.0.1-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 192 kB
  • sloc: makefile: 15
file content (45 lines) | stat: -rw-r--r-- 1,036 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package integration

import (
	"net"
	"strconv"
	"testing"

	"github.com/k0swe/wsjtx-go/v4"
	"github.com/stretchr/testify/suite"
)

type integrationTestSuite struct {
	suite.Suite
	server  wsjtx.Server
	msgChan chan interface{}
	errChan chan error
	fake    *WsjtxFake
}

func TestIntegrationSuite(t *testing.T) {
	suite.Run(t, &integrationTestSuite{})
}

func (s *integrationTestSuite) SetupSuite() {
	var err error
	s.msgChan = make(chan interface{}, 5)
	s.errChan = make(chan error, 5)
	s.server, err = wsjtx.MakeServerGiven(net.ParseIP("127.0.0.1"), 0)
	s.Require().NoError(err)
	go s.server.ListenToWsjtx(s.msgChan, s.errChan)
	s.T().Log("suite started server listening")
}

func (s *integrationTestSuite) SetupTest() {
	_, portStr, _ := net.SplitHostPort(s.server.LocalAddr().String())
	port, _ := strconv.Atoi(portStr)
	var err error
	s.fake, err = NewFake(&net.UDPAddr{Port: port}, s.T())
	s.Require().NoError(err)
	s.T().Log("suite reports fake is connected")
}

func (s *integrationTestSuite) TearDownTest() {
	s.fake.Stop()
}