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.
34 lines
613 B
Go
34 lines
613 B
Go
package domain
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
func TestMockFileRepo(t *testing.T) {
|
|
r := new(MockFileRepository)
|
|
r.NextId = 0
|
|
r.IdIdx = make(map[int64]*UserAgent)
|
|
r.NameIdx = make(map[string]*UserAgent)
|
|
|
|
all, err := r.All()
|
|
|
|
if len(all) != 0 && err != nil {
|
|
t.Errorf("New repo should be empty")
|
|
}
|
|
|
|
ua := UserAgent {23, "", time.Now(), time.Duration(time.Hour * 3), FileSizeQuota {1000, 0} }
|
|
|
|
r.Create(ua)
|
|
|
|
all, err = r.All()
|
|
|
|
if len(all) != 1 && err != nil {
|
|
t.Errorf("After adding there should be a Useragent")
|
|
}
|
|
|
|
if ua.ID != 23 {
|
|
t.Errorf("It does not change the original UserAgent")
|
|
}
|
|
}
|