diff options
Diffstat (limited to 'pkg/tcpip/tcpip_test.go')
-rw-r--r-- | pkg/tcpip/tcpip_test.go | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/pkg/tcpip/tcpip_test.go b/pkg/tcpip/tcpip_test.go index 361e359d4..1f7b04398 100644 --- a/pkg/tcpip/tcpip_test.go +++ b/pkg/tcpip/tcpip_test.go @@ -15,7 +15,9 @@ package tcpip import ( + "fmt" "net" + "strings" "testing" ) @@ -193,3 +195,23 @@ func TestAddressString(t *testing.T) { } } } + +func TestStatsString(t *testing.T) { + got := fmt.Sprintf("%+v", Stats{}.FillIn()) + + matchers := []string{ + // Print root-level stats correctly. + "UnknownProtocolRcvdPackets:0", + // Print protocol-specific stats correctly. + "TCP:{ActiveConnectionOpenings:0", + } + + for _, m := range matchers { + if !strings.Contains(got, m) { + t.Errorf("string.Contains(got, %q) = false", m) + } + } + if t.Failed() { + t.Logf(`got = fmt.Sprintf("%%+v", Stats{}.FillIn()) = %q`, got) + } +} |