go.ligato.io/vpp-agent/v3@v3.5.0/plugins/vpp/ifplugin/vppcalls/vpp2101/mtu_vppcalls_test.go (about)

     1  //  Copyright (c) 2019 Cisco and/or its affiliates.
     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  package vpp2101_test
    16  
    17  import (
    18  	"testing"
    19  
    20  	. "github.com/onsi/gomega"
    21  
    22  	vpp_ifs "go.ligato.io/vpp-agent/v3/plugins/vpp/binapi/vpp2101/interface"
    23  )
    24  
    25  func TestSetInterfaceMtu(t *testing.T) {
    26  	ctx, ifHandler := ifTestSetup(t)
    27  	defer ctx.TeardownTestCtx()
    28  
    29  	ctx.MockVpp.MockReply(&vpp_ifs.HwInterfaceSetMtuReply{})
    30  
    31  	err := ifHandler.SetInterfaceMtu(1, 1500)
    32  
    33  	Expect(err).To(BeNil())
    34  	vppMsg, ok := ctx.MockChannel.Msg.(*vpp_ifs.HwInterfaceSetMtu)
    35  	Expect(ok).To(BeTrue())
    36  	Expect(vppMsg.SwIfIndex).To(BeEquivalentTo(1))
    37  	Expect(vppMsg.Mtu).To(BeEquivalentTo(1500))
    38  }
    39  
    40  func TestSetInterfaceMtuError(t *testing.T) {
    41  	ctx, ifHandler := ifTestSetup(t)
    42  	defer ctx.TeardownTestCtx()
    43  
    44  	ctx.MockVpp.MockReply(&vpp_ifs.HwInterfaceSetMtu{})
    45  
    46  	err := ifHandler.SetInterfaceMtu(1, 1500)
    47  
    48  	Expect(err).ToNot(BeNil())
    49  }
    50  
    51  func TestSetInterfaceMtuRetval(t *testing.T) {
    52  	ctx, ifHandler := ifTestSetup(t)
    53  	defer ctx.TeardownTestCtx()
    54  
    55  	ctx.MockVpp.MockReply(&vpp_ifs.HwInterfaceSetMtuReply{
    56  		Retval: 1,
    57  	})
    58  
    59  	err := ifHandler.SetInterfaceMtu(1, 1500)
    60  
    61  	Expect(err).ToNot(BeNil())
    62  }