go.ligato.io/vpp-agent/v3@v3.5.0/plugins/telemetry/vppcalls/telemetry_stats_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 vppcalls 16 17 import ( 18 "testing" 19 20 . "github.com/onsi/gomega" 21 ) 22 23 func TestSplitErrorName(t *testing.T) { 24 tests := []struct { 25 name string 26 input string 27 expNode, expReason string 28 }{ 29 {"basic", "ipsec-input-ip4/IPSEC pkts received", "ipsec-input-ip4", "IPSEC pkts received"}, 30 {"ifname", "memif1/1001-output/interface is down", "memif1/1001-output", "interface is down"}, 31 {"reslash", "tcp6-input/inconsistent ip/tcp lengths", "tcp6-input", "inconsistent ip/tcp lengths"}, 32 {"toomany", "memif1/1001-output/Unrecognized / unknown chunk or chunk-state mismatch", "memif1/1001-output", "Unrecognized / unknown chunk or chunk-state mismatch"}, 33 } 34 for _, test := range tests { 35 t.Run(test.name, func(t *testing.T) { 36 RegisterTestingT(t) 37 38 node, reason := SplitErrorName(test.input) 39 Expect(node).To(Equal(test.expNode)) 40 Expect(reason).To(Equal(test.expReason)) 41 }) 42 } 43 }