Test store with uri arguments

This commit is contained in:
Adrien Marquès 2019-11-19 16:15:44 +01:00
parent 613233faef
commit 44d19e8b65
Signed by: xdrm-brackets
GPG Key ID: D75243CA236D825E
1 changed files with 34 additions and 0 deletions

View File

@ -32,3 +32,37 @@ func TestEmptyStore(t *testing.T) {
t.Fail() 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()
}
})
}
}