github.com/looshlee/beatles@v0.0.0-20220727174639-742810ab631c/pkg/maps/lbmap/lbmap_test.go (about)

     1  // Copyright 2018-2019 Authors of Cilium
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  // +build !privileged_tests
    16  
    17  package lbmap
    18  
    19  import (
    20  	"net"
    21  	"testing"
    22  
    23  	"github.com/cilium/cilium/pkg/u8proto"
    24  
    25  	. "gopkg.in/check.v1"
    26  )
    27  
    28  // Hook up gocheck into the "go test" runner.
    29  func Test(t *testing.T) {
    30  	TestingT(t)
    31  }
    32  
    33  type LBMapTestSuite struct{}
    34  
    35  var _ = Suite(&LBMapTestSuite{})
    36  
    37  func (b *LBMapTestSuite) TestBackendAddrID(c *C) {
    38  	b4, err := NewBackend4Value(net.ParseIP("1.1.1.1"), 80, u8proto.ANY)
    39  	c.Assert(err, IsNil)
    40  	v4 := NewService4Value(0, net.ParseIP("1.1.1.1"), 80, 0, 0)
    41  	c.Assert(b4.BackendAddrID(), Equals, v4.BackendAddrID())
    42  
    43  	b6, err := NewBackend6Value(net.ParseIP("f00d::0:0"), 80, u8proto.ANY)
    44  	c.Assert(err, IsNil)
    45  	v6 := NewService6Value(0, net.ParseIP("f00d::0:0"), 80, 0, 0)
    46  	c.Assert(b6.BackendAddrID(), Equals, v6.BackendAddrID())
    47  
    48  }