github.com/hechain20/hechain@v0.0.0-20220316014945-b544036ba106/integration/gateway/gateway_suite_test.go (about)

     1  /*
     2  Copyright hechain All Rights Reserved.
     3  
     4  SPDX-License-Identifier: Apache-2.0
     5  */
     6  
     7  package gateway
     8  
     9  import (
    10  	"encoding/json"
    11  	"testing"
    12  
    13  	"github.com/hechain20/hechain/common/flogging"
    14  	"github.com/hechain20/hechain/integration"
    15  	"github.com/hechain20/hechain/integration/nwo"
    16  	. "github.com/onsi/ginkgo"
    17  	. "github.com/onsi/gomega"
    18  )
    19  
    20  func TestGateway(t *testing.T) {
    21  	RegisterFailHandler(Fail)
    22  	RunSpecs(t, "Gateway Service Suite")
    23  }
    24  
    25  var (
    26  	buildServer *nwo.BuildServer
    27  	components  *nwo.Components
    28  )
    29  
    30  var _ = SynchronizedBeforeSuite(func() []byte {
    31  	buildServer = nwo.NewBuildServer()
    32  	buildServer.Serve()
    33  
    34  	components = buildServer.Components()
    35  	payload, err := json.Marshal(components)
    36  	Expect(err).NotTo(HaveOccurred())
    37  
    38  	return payload
    39  }, func(payload []byte) {
    40  	err := json.Unmarshal(payload, &components)
    41  	Expect(err).NotTo(HaveOccurred())
    42  
    43  	flogging.SetWriter(GinkgoWriter)
    44  })
    45  
    46  var _ = SynchronizedAfterSuite(func() {
    47  }, func() {
    48  	buildServer.Shutdown()
    49  })
    50  
    51  func StartPort() int {
    52  	return integration.GatewayBasePort.StartPortForNode()
    53  }