refac: missing mutation tests, spa specs, checks shown to pass, touch targets, catalogue entry, production code
This commit is contained in:
1 parent
7c15206170
commit
3e02e14da4
48 files changed
+2173
-83
No files matched your search
@@ -12,6 +12,7 @@ import (
|
||||
"net/http/httptest"
|
||||
"sort"
|
||||
"strings"
|
||||
"sync"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@@ -24,6 +25,7 @@ type authorDeleteCall struct {
|
||||
}
|
||||
|
||||
type mockAuthorRepo struct {
|
||||
mu sync.Mutex
|
||||
authors map[uint32]author.Author
|
||||
articles *mockArticleRepo
|
||||
nextID uint32
|
||||
@@ -99,6 +101,8 @@ func (m *mockAuthorRepo) sortedIDsDescending() []uint32 {
|
||||
}
|
||||
|
||||
func (m *mockAuthorRepo) List(query author.ListQuery) (author.Page, error) {
|
||||
m.mu.Lock()
|
||||
defer m.mu.Unlock()
|
||||
if err := m.fail.trigger("List"); err != nil {
|
||||
return author.Page{}, err
|
||||
}
|
||||
@@ -120,6 +124,8 @@ func (m *mockAuthorRepo) List(query author.ListQuery) (author.Page, error) {
|
||||
}
|
||||
|
||||
func (m *mockAuthorRepo) Get(id uint32) (author.Author, error) {
|
||||
m.mu.Lock()
|
||||
defer m.mu.Unlock()
|
||||
if err := m.fail.trigger("Get"); err != nil {
|
||||
return author.Author{}, err
|
||||
}
|
||||
@@ -131,6 +137,8 @@ func (m *mockAuthorRepo) Get(id uint32) (author.Author, error) {
|
||||
}
|
||||
|
||||
func (m *mockAuthorRepo) GetBySlug(slug string) (author.Author, error) {
|
||||
m.mu.Lock()
|
||||
defer m.mu.Unlock()
|
||||
if err := m.fail.trigger("GetBySlug"); err != nil {
|
||||
return author.Author{}, err
|
||||
}
|
||||
@@ -143,6 +151,8 @@ func (m *mockAuthorRepo) GetBySlug(slug string) (author.Author, error) {
|
||||
}
|
||||
|
||||
func (m *mockAuthorRepo) GetByUserID(userID uint32) (author.Author, error) {
|
||||
m.mu.Lock()
|
||||
defer m.mu.Unlock()
|
||||
if err := m.fail.trigger("GetByUserID"); err != nil {
|
||||
return author.Author{}, err
|
||||
}
|
||||
@@ -170,6 +180,8 @@ func (m *mockAuthorRepo) conflictFor(candidate author.Author) error {
|
||||
}
|
||||
|
||||
func (m *mockAuthorRepo) Create(a author.Author) (author.Author, error) {
|
||||
m.mu.Lock()
|
||||
defer m.mu.Unlock()
|
||||
m.createCalls++
|
||||
if err := m.fail.trigger("Create"); err != nil {
|
||||
return author.Author{}, err
|
||||
@@ -186,6 +198,8 @@ func (m *mockAuthorRepo) Create(a author.Author) (author.Author, error) {
|
||||
}
|
||||
|
||||
func (m *mockAuthorRepo) Update(a author.Author) (author.Author, error) {
|
||||
m.mu.Lock()
|
||||
defer m.mu.Unlock()
|
||||
if err := m.fail.trigger("Update"); err != nil {
|
||||
return author.Author{}, err
|
||||
}
|
||||
@@ -201,6 +215,8 @@ func (m *mockAuthorRepo) Update(a author.Author) (author.Author, error) {
|
||||
}
|
||||
|
||||
func (m *mockAuthorRepo) DeleteMovingCredits(id uint32, reassignTo *uint32) error {
|
||||
m.mu.Lock()
|
||||
defer m.mu.Unlock()
|
||||
m.deleteCalls = append(m.deleteCalls, authorDeleteCall{id: id, reassignTo: reassignTo})
|
||||
if err := m.fail.trigger("DeleteMovingCredits"); err != nil {
|
||||
return err
|
||||
@@ -221,6 +237,8 @@ func (m *mockAuthorRepo) DeleteMovingCredits(id uint32, reassignTo *uint32) erro
|
||||
}
|
||||
|
||||
func (m *mockAuthorRepo) DeleteUncrediting(id uint32) error {
|
||||
m.mu.Lock()
|
||||
defer m.mu.Unlock()
|
||||
m.deleteCalls = append(m.deleteCalls, authorDeleteCall{id: id})
|
||||
if err := m.fail.trigger("DeleteMovingCredits"); err != nil {
|
||||
return err
|
||||
@@ -273,6 +291,8 @@ func containsID(ids []uint32, wanted uint32) bool {
|
||||
}
|
||||
|
||||
func (m *mockAuthorRepo) AvatarUsage() (map[uint32]int, error) {
|
||||
m.mu.Lock()
|
||||
defer m.mu.Unlock()
|
||||
usage := map[uint32]int{}
|
||||
for _, a := range m.authors {
|
||||
if a.AvatarID != nil {
|
||||
@@ -283,6 +303,8 @@ func (m *mockAuthorRepo) AvatarUsage() (map[uint32]int, error) {
|
||||
}
|
||||
|
||||
func (m *mockAuthorRepo) FindByAvatar(imageID uint32) ([]author.Author, error) {
|
||||
m.mu.Lock()
|
||||
defer m.mu.Unlock()
|
||||
if err := m.fail.trigger("FindByAvatar"); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -302,6 +324,8 @@ func (m *mockAuthorRepo) sortedIDsAscending() []uint32 {
|
||||
}
|
||||
|
||||
func (m *mockAuthorRepo) ClearAvatar(imageID uint32) ([]uint32, error) {
|
||||
m.mu.Lock()
|
||||
defer m.mu.Unlock()
|
||||
cleared := []uint32{}
|
||||
for _, id := range m.sortedIDsDescending() {
|
||||
a := m.authors[id]
|
||||
@@ -315,6 +339,8 @@ func (m *mockAuthorRepo) ClearAvatar(imageID uint32) ([]uint32, error) {
|
||||
}
|
||||
|
||||
func (m *mockAuthorRepo) AssignAvatar(authorIDs []uint32, imageID uint32) error {
|
||||
m.mu.Lock()
|
||||
defer m.mu.Unlock()
|
||||
for _, id := range authorIDs {
|
||||
a := m.authors[id]
|
||||
a.AvatarID = idPointer(imageID)
|
||||
@@ -324,6 +350,8 @@ func (m *mockAuthorRepo) AssignAvatar(authorIDs []uint32, imageID uint32) error
|
||||
}
|
||||
|
||||
func (m *mockAuthorRepo) RepointAvatar(fromImageIDs []uint32, toImageID uint32) (int, error) {
|
||||
m.mu.Lock()
|
||||
defer m.mu.Unlock()
|
||||
if err := m.fail.trigger("RepointAvatar"); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user