From 0c158febf0051e786c9ed08a7d6f73018a0cb226 Mon Sep 17 00:00:00 2001 From: "M. Mert Yildiran" Date: Tue, 8 Feb 2022 14:23:40 +0300 Subject: [PATCH] Add `TestRegister`, `TestMacros` and `TestPing` methods --- tap/extensions/http/main_test.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tap/extensions/http/main_test.go b/tap/extensions/http/main_test.go index 29bfbcc15..06fe18cd3 100644 --- a/tap/extensions/http/main_test.go +++ b/tap/extensions/http/main_test.go @@ -34,6 +34,30 @@ const ( testUpdate = "TEST_UPDATE" ) +func TestRegister(t *testing.T) { + dissector := NewDissector() + extension := &api.Extension{} + dissector.Register(extension) + assert.Equal(t, "http", extension.Protocol.Name) + assert.NotNil(t, extension.MatcherMap) +} + +func TestMacros(t *testing.T) { + expectedMacros := map[string]string{ + "http": `proto.name == "http" and proto.version.startsWith("1")`, + "http2": `proto.name == "http" and proto.version == "2.0"`, + "grpc": `proto.name == "http" and proto.version == "2.0" and proto.macro == "grpc"`, + } + dissector := NewDissector() + macros := dissector.Macros() + assert.Equal(t, expectedMacros, macros) +} + +func TestPing(t *testing.T) { + dissector := NewDissector() + dissector.Ping() +} + func TestDissect(t *testing.T) { var testUpdateEnabled bool _, present := os.LookupEnv(testUpdate)