github.com/vmware/transport-go@v1.3.4/plank/pkg/server/test_suite_harness_test.go (about)

     1  package server
     2  
     3  import (
     4  	"github.com/stretchr/testify/assert"
     5  	"github.com/stretchr/testify/suite"
     6  	"github.com/vmware/transport-go/bus"
     7  	"github.com/vmware/transport-go/model"
     8  	"github.com/vmware/transport-go/service"
     9  	"os"
    10  	"testing"
    11  )
    12  
    13  func TestGetBasicTestServerConfig(t *testing.T) {
    14  	config := GetBasicTestServerConfig("/", "stdout", "stdout", "stderr", 999, true)
    15  	assert.Equal(t, "/", config.RootDir)
    16  	assert.Equal(t, 999, config.Port)
    17  }
    18  
    19  // define mock integration suite
    20  type testPlankTestIntegration struct {
    21  	PlankIntegrationTestSuite
    22  }
    23  
    24  func (m *testPlankTestIntegration) SetPlatformServer(s PlatformServer) {
    25  	m.PlatformServer = s
    26  }
    27  func (m *testPlankTestIntegration) SetSysChan(c chan os.Signal) {
    28  	m.Syschan = c
    29  }
    30  func (m *testPlankTestIntegration) SetChannelManager(cm bus.ChannelManager) {
    31  	m.ChannelManager = cm
    32  }
    33  func (m *testPlankTestIntegration) SetBus(eventBus bus.EventBus) {
    34  	m.EventBus = eventBus
    35  }
    36  
    37  func TestSetupPlankTestSuiteForTest(t *testing.T) {
    38  	b := bus.ResetBus()
    39  	service.ResetServiceRegistry()
    40  	cm := b.GetChannelManager()
    41  	pit := &PlankIntegrationTestSuite{
    42  		Suite:          suite.Suite{},
    43  		PlatformServer: nil,
    44  		Syschan:        make(chan os.Signal),
    45  		ChannelManager: cm,
    46  		EventBus:       b,
    47  	}
    48  
    49  	test := &testPlankTestIntegration{}
    50  	SetupPlankTestSuiteForTest(pit, test)
    51  	assert.Equal(t, cm, test.ChannelManager)
    52  	assert.Equal(t, b, test.EventBus)
    53  	assert.Nil(t, nil, test.PlatformServer)
    54  }
    55  
    56  type testService struct {
    57  }
    58  
    59  func (t *testService) HandleServiceRequest(rt *model.Request, c service.FabricServiceCore) {
    60  }
    61  
    62  func TestSetupPlankTestSuite(t *testing.T) {
    63  	suite, err := SetupPlankTestSuite(&testService{}, "nowhere", 62986, nil)
    64  	assert.NoError(t, err)
    65  	assert.NotNil(t, suite)
    66  }