From 44d19e8b65c7058f8d74802e86934ee6cb4c431c Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Tue, 19 Nov 2019 16:15:44 +0100 Subject: [PATCH] Test store with uri arguments --- internal/reqdata/store_test.go | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/internal/reqdata/store_test.go b/internal/reqdata/store_test.go index c973268..6a15342 100644 --- a/internal/reqdata/store_test.go +++ b/internal/reqdata/store_test.go @@ -32,3 +32,37 @@ func TestEmptyStore(t *testing.T) { t.Fail() } } + +func TestStoreWithUri(t *testing.T) { + urilist := []string{"abc", "def"} + store := New(urilist, nil) + + if len(store.URI) != len(urilist) { + t.Errorf("store 'Set' should contain %d elements (got %d)", len(urilist), len(store.URI)) + t.Fail() + } + if len(store.Set) != len(urilist) { + t.Errorf("store 'Set' should contain %d elements (got %d)", len(urilist), len(store.Set)) + t.Fail() + } + + for i, value := range urilist { + + t.Run(fmt.Sprintf("URL#%d='%s'", i, value), func(t *testing.T) { + key := fmt.Sprintf("URL#%d", i) + element, isset := store.Set[key] + + if !isset { + t.Errorf("store should contain element with key '%s'", key) + t.Failed() + } + + if element.Value != value { + t.Errorf("store[%s] should return '%s' (got '%s')", key, value, element.Value) + t.Failed() + } + }) + + } + +}