From ada59119cceb07f4fcd265da88cf9b1141885f29 Mon Sep 17 00:00:00 2001 From: Vasiliy Tolstov Date: Sat, 2 Oct 2021 18:34:22 +0300 Subject: [PATCH] util/http: add test case Signed-off-by: Vasiliy Tolstov --- util/http/trie_test.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/util/http/trie_test.go b/util/http/trie_test.go index 8e51df76..25e95d49 100644 --- a/util/http/trie_test.go +++ b/util/http/trie_test.go @@ -5,6 +5,22 @@ import ( "testing" ) +func TestTrieFixedPattern(t *testing.T) { + type handler struct { + name string + } + tr := NewTrie() + tr.Insert([]string{http.MethodPut}, "/v1/create/{id}", &handler{name: "pattern"}) + tr.Insert([]string{http.MethodPut}, "/v1/create/12", &handler{name: "fixed"}) + h, _, ok := tr.Search(http.MethodPut, "/v1/create/12", IgnoreCase(false)) + if !ok { + t.Fatalf("unexpected error") + } + if h.(*handler).name != "fixed" { + t.Fatalf("invalid handler %v", h) + } +} + func TestTrieIgnoreCase(t *testing.T) { type handler struct { name string