You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
bog/infrastructure/memory/namespace/repository_test.go

44 lines
684 B
Go

package namespace
import (
"caj-larsson/bog/dataswamp/namespace"
"github.com/matryer/is"
"testing"
"time"
)
func TestUserAgentRepo(t *testing.T) {
is := is.New(t)
r := NewRepository()
all, err := r.All()
is.NoErr(err)
is.Equal(len(all), 0)
ns := namespace.Namespace{23, "n1", time.Now(), time.Duration(time.Hour * 3), namespace.FileSizeQuota{1000, 0}}
ns1, _ := r.Create(ns)
ns.Name = "n2"
ns2, _ := r.Create(ns)
is.True(ns1 != ns2)
all, err = r.All()
is.NoErr(err)
is.Equal(len(all), 2)
is.Equal(ns.ID, int64(23))
ns3, _ := r.GetByName("n2")
is.Equal(ns3, ns2)
is.NoErr(r.Delete(ns2.ID))
all, err = r.All()
is.NoErr(err)
is.Equal(len(all), 1)
}