~evanj/cms

356e3f389fe3e9167cffb270f41b6f2b22eb202a — Evan J 2 months ago a1db405
Feat(context): Completed adding context to data layer. Refactored tests
to use context.
M internal/c/c_mock.go => internal/c/c_mock.go +9 -8
@@ 5,6 5,7 @@
package c

import (
	context "context"
	user "git.sr.ht/~evanj/cms/internal/m/user"
	gomock "github.com/golang/mock/gomock"
	reflect "reflect"


@@ 34,31 35,31 @@ func (m *Mockdber) EXPECT() *MockdberMockRecorder {
}

// UserGet mocks base method
func (m *Mockdber) UserGet(username, password string) (user.User, error) {
func (m *Mockdber) UserGet(ctx context.Context, username, password string) (user.User, error) {
	m.ctrl.T.Helper()
	ret := m.ctrl.Call(m, "UserGet", username, password)
	ret := m.ctrl.Call(m, "UserGet", ctx, username, password)
	ret0, _ := ret[0].(user.User)
	ret1, _ := ret[1].(error)
	return ret0, ret1
}

// UserGet indicates an expected call of UserGet
func (mr *MockdberMockRecorder) UserGet(username, password interface{}) *gomock.Call {
func (mr *MockdberMockRecorder) UserGet(ctx, username, password interface{}) *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UserGet", reflect.TypeOf((*Mockdber)(nil).UserGet), username, password)
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UserGet", reflect.TypeOf((*Mockdber)(nil).UserGet), ctx, username, password)
}

// UserGetFromToken mocks base method
func (m *Mockdber) UserGetFromToken(token string) (user.User, error) {
func (m *Mockdber) UserGetFromToken(ctx context.Context, token string) (user.User, error) {
	m.ctrl.T.Helper()
	ret := m.ctrl.Call(m, "UserGetFromToken", token)
	ret := m.ctrl.Call(m, "UserGetFromToken", ctx, token)
	ret0, _ := ret[0].(user.User)
	ret1, _ := ret[1].(error)
	return ret0, ret1
}

// UserGetFromToken indicates an expected call of UserGetFromToken
func (mr *MockdberMockRecorder) UserGetFromToken(token interface{}) *gomock.Call {
func (mr *MockdberMockRecorder) UserGetFromToken(ctx, token interface{}) *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UserGetFromToken", reflect.TypeOf((*Mockdber)(nil).UserGetFromToken), token)
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UserGetFromToken", reflect.TypeOf((*Mockdber)(nil).UserGetFromToken), ctx, token)
}

M internal/c/c_test.go => internal/c/c_test.go +4 -3
@@ 21,6 21,7 @@ import (

var (
	tmpl = template.Must(template.New("c_test").Parse("sup earth"))
	ctx  = gomock.Any()
)

type server struct{ *c.Controller }


@@ 210,7 211,7 @@ func TestUserFromBasicAuth(t *testing.T) {
		u     = userT.NewMock(uname, upass)
	)

	db.EXPECT().UserGet(uname, upass).Return(u, nil).AnyTimes()
	db.EXPECT().UserGet(ctx, uname, upass).Return(u, nil).AnyTimes()

	req, _ := http.NewRequest("GET", ts.URL, nil)
	req.SetBasicAuth(uname, upass)


@@ 235,7 236,7 @@ func TestUserFromFromCookie(t *testing.T) {
		u      = userT.NewMock(uname, upass)
	)

	db.EXPECT().UserGetFromToken(cookie).Return(u, nil).AnyTimes()
	db.EXPECT().UserGetFromToken(ctx, cookie).Return(u, nil).AnyTimes()

	req, _ := http.NewRequest("GET", ts.URL, nil)
	req.AddCookie(&http.Cookie{


@@ 262,7 263,7 @@ func TestUserFromFromCookieFail(t *testing.T) {
		cookie = uuid.New().String()
	)

	db.EXPECT().UserGetFromToken(cookie).Return(nil, errors.New("no user")).AnyTimes()
	db.EXPECT().UserGetFromToken(ctx, cookie).Return(nil, errors.New("no user")).AnyTimes()

	req, _ := http.NewRequest("GET", ts.URL, nil)
	res, _ := http.DefaultClient.Do(req)

M internal/c/content/content.go => internal/c/content/content.go +2 -2
@@ 47,8 47,8 @@ type dber interface {
	ContentTypeGet(ctx context.Context, u user.User, space space.Space, contenttypeID string) (contenttype.ContentType, error)
	ContentNew(ctx context.Context, u user.User, space space.Space, ct contenttype.ContentType, params []db.ContentNewParam) (content.Content, error)
	ContentGet(ctx context.Context, u user.User, space space.Space, ct contenttype.ContentType, contentID string) (content.Content, error)
	ContentUpdate(ctx context.Context, u user.User, space space.Space, ct contenttype.ContentType, content content.Content, newParams []db.ContentNewParam, updateParams []db.ContentUpdateParam) (content.Content, error)
	ContentDelete(ctx context.Context, u user.User, space space.Space, ct contenttype.ContentType, content content.Content) error
	ContentUpdate(ctx context.Context, u user.User, space space.Space, ct contenttype.ContentType, c content.Content, newParams []db.ContentNewParam, updateParams []db.ContentUpdateParam) (content.Content, error)
	ContentDelete(ctx context.Context, u user.User, space space.Space, ct contenttype.ContentType, c content.Content) error
	ContentSearch(ctx context.Context, u user.User, space space.Space, ct contenttype.ContentType, name, query string, before int) (content.ContentList, error)
}


M internal/c/content/content_mock.go => internal/c/content/content_mock.go +53 -54
@@ 6,9 6,6 @@ package content

import (
	context "context"
	io "io"
	reflect "reflect"

	content "git.sr.ht/~evanj/cms/internal/m/content"
	contenttype "git.sr.ht/~evanj/cms/internal/m/contenttype"
	space "git.sr.ht/~evanj/cms/internal/m/space"


@@ 16,163 13,165 @@ import (
	db "git.sr.ht/~evanj/cms/internal/s/db"
	hook "git.sr.ht/~evanj/cms/internal/s/hook"
	gomock "github.com/golang/mock/gomock"
	io "io"
	reflect "reflect"
)

// MockDBer is a mock of DBer interface
type MockDBer struct {
// Mockdber is a mock of dber interface
type Mockdber struct {
	ctrl     *gomock.Controller
	recorder *MockDBerMockRecorder
	recorder *MockdberMockRecorder
}

// MockDBerMockRecorder is the mock recorder for MockDBer
type MockDBerMockRecorder struct {
	mock *MockDBer
// MockdberMockRecorder is the mock recorder for Mockdber
type MockdberMockRecorder struct {
	mock *Mockdber
}

// NewMockDBer creates a new mock instance
func NewMockDBer(ctrl *gomock.Controller) *MockDBer {
	mock := &MockDBer{ctrl: ctrl}
	mock.recorder = &MockDBerMockRecorder{mock}
// NewMockdber creates a new mock instance
func NewMockdber(ctrl *gomock.Controller) *Mockdber {
	mock := &Mockdber{ctrl: ctrl}
	mock.recorder = &MockdberMockRecorder{mock}
	return mock
}

// EXPECT returns an object that allows the caller to indicate expected use
func (m *MockDBer) EXPECT() *MockDBerMockRecorder {
func (m *Mockdber) EXPECT() *MockdberMockRecorder {
	return m.recorder
}

// UserGet mocks base method
func (m *MockDBer) UserGet(username, password string) (user.User, error) {
func (m *Mockdber) UserGet(ctx context.Context, username, password string) (user.User, error) {
	m.ctrl.T.Helper()
	ret := m.ctrl.Call(m, "UserGet", username, password)
	ret := m.ctrl.Call(m, "UserGet", ctx, username, password)
	ret0, _ := ret[0].(user.User)
	ret1, _ := ret[1].(error)
	return ret0, ret1
}

// UserGet indicates an expected call of UserGet
func (mr *MockDBerMockRecorder) UserGet(username, password interface{}) *gomock.Call {
func (mr *MockdberMockRecorder) UserGet(ctx, username, password interface{}) *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UserGet", reflect.TypeOf((*MockDBer)(nil).UserGet), username, password)
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UserGet", reflect.TypeOf((*Mockdber)(nil).UserGet), ctx, username, password)
}

// UserGetFromToken mocks base method
func (m *MockDBer) UserGetFromToken(token string) (user.User, error) {
func (m *Mockdber) UserGetFromToken(ctx context.Context, token string) (user.User, error) {
	m.ctrl.T.Helper()
	ret := m.ctrl.Call(m, "UserGetFromToken", token)
	ret := m.ctrl.Call(m, "UserGetFromToken", ctx, token)
	ret0, _ := ret[0].(user.User)
	ret1, _ := ret[1].(error)
	return ret0, ret1
}

// UserGetFromToken indicates an expected call of UserGetFromToken
func (mr *MockDBerMockRecorder) UserGetFromToken(token interface{}) *gomock.Call {
func (mr *MockdberMockRecorder) UserGetFromToken(ctx, token interface{}) *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UserGetFromToken", reflect.TypeOf((*MockDBer)(nil).UserGetFromToken), token)
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UserGetFromToken", reflect.TypeOf((*Mockdber)(nil).UserGetFromToken), ctx, token)
}

// SpaceGet mocks base method
func (m *MockDBer) SpaceGet(user user.User, spaceID string) (space.Space, error) {
func (m *Mockdber) SpaceGet(ctx context.Context, user user.User, spaceID string) (space.Space, error) {
	m.ctrl.T.Helper()
	ret := m.ctrl.Call(m, "SpaceGet", user, spaceID)
	ret := m.ctrl.Call(m, "SpaceGet", ctx, user, spaceID)
	ret0, _ := ret[0].(space.Space)
	ret1, _ := ret[1].(error)
	return ret0, ret1
}

// SpaceGet indicates an expected call of SpaceGet
func (mr *MockDBerMockRecorder) SpaceGet(user, spaceID interface{}) *gomock.Call {
func (mr *MockdberMockRecorder) SpaceGet(ctx, user, spaceID interface{}) *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SpaceGet", reflect.TypeOf((*MockDBer)(nil).SpaceGet), user, spaceID)
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SpaceGet", reflect.TypeOf((*Mockdber)(nil).SpaceGet), ctx, user, spaceID)
}

// ContentTypeGet mocks base method
func (m *MockDBer) ContentTypeGet(u user.User, space space.Space, contenttypeID string) (contenttype.ContentType, error) {
func (m *Mockdber) ContentTypeGet(ctx context.Context, u user.User, space space.Space, contenttypeID string) (contenttype.ContentType, error) {
	m.ctrl.T.Helper()
	ret := m.ctrl.Call(m, "ContentTypeGet", u, space, contenttypeID)
	ret := m.ctrl.Call(m, "ContentTypeGet", ctx, u, space, contenttypeID)
	ret0, _ := ret[0].(contenttype.ContentType)
	ret1, _ := ret[1].(error)
	return ret0, ret1
}

// ContentTypeGet indicates an expected call of ContentTypeGet
func (mr *MockDBerMockRecorder) ContentTypeGet(u, space, contenttypeID interface{}) *gomock.Call {
func (mr *MockdberMockRecorder) ContentTypeGet(ctx, u, space, contenttypeID interface{}) *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ContentTypeGet", reflect.TypeOf((*MockDBer)(nil).ContentTypeGet), u, space, contenttypeID)
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ContentTypeGet", reflect.TypeOf((*Mockdber)(nil).ContentTypeGet), ctx, u, space, contenttypeID)
}

// ContentNew mocks base method
func (m *MockDBer) ContentNew(u user.User, space space.Space, ct contenttype.ContentType, params []db.ContentNewParam) (content.Content, error) {
func (m *Mockdber) ContentNew(ctx context.Context, u user.User, space space.Space, ct contenttype.ContentType, params []db.ContentNewParam) (content.Content, error) {
	m.ctrl.T.Helper()
	ret := m.ctrl.Call(m, "ContentNew", u, space, ct, params)
	ret := m.ctrl.Call(m, "ContentNew", ctx, u, space, ct, params)
	ret0, _ := ret[0].(content.Content)
	ret1, _ := ret[1].(error)
	return ret0, ret1
}

// ContentNew indicates an expected call of ContentNew
func (mr *MockDBerMockRecorder) ContentNew(u, space, ct, params interface{}) *gomock.Call {
func (mr *MockdberMockRecorder) ContentNew(ctx, u, space, ct, params interface{}) *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ContentNew", reflect.TypeOf((*MockDBer)(nil).ContentNew), u, space, ct, params)
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ContentNew", reflect.TypeOf((*Mockdber)(nil).ContentNew), ctx, u, space, ct, params)
}

// ContentGet mocks base method
func (m *MockDBer) ContentGet(u user.User, space space.Space, ct contenttype.ContentType, contentID string) (content.Content, error) {
func (m *Mockdber) ContentGet(ctx context.Context, u user.User, space space.Space, ct contenttype.ContentType, contentID string) (content.Content, error) {
	m.ctrl.T.Helper()
	ret := m.ctrl.Call(m, "ContentGet", u, space, ct, contentID)
	ret := m.ctrl.Call(m, "ContentGet", ctx, u, space, ct, contentID)
	ret0, _ := ret[0].(content.Content)
	ret1, _ := ret[1].(error)
	return ret0, ret1
}

// ContentGet indicates an expected call of ContentGet
func (mr *MockDBerMockRecorder) ContentGet(u, space, ct, contentID interface{}) *gomock.Call {
func (mr *MockdberMockRecorder) ContentGet(ctx, u, space, ct, contentID interface{}) *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ContentGet", reflect.TypeOf((*MockDBer)(nil).ContentGet), u, space, ct, contentID)
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ContentGet", reflect.TypeOf((*Mockdber)(nil).ContentGet), ctx, u, space, ct, contentID)
}

// ContentUpdate mocks base method
func (m *MockDBer) ContentUpdate(u user.User, space space.Space, ct contenttype.ContentType, c content.Content, newParams []db.ContentNewParam, updateParams []db.ContentUpdateParam) (content.Content, error) {
func (m *Mockdber) ContentUpdate(ctx context.Context, u user.User, space space.Space, ct contenttype.ContentType, c content.Content, newParams []db.ContentNewParam, updateParams []db.ContentUpdateParam) (content.Content, error) {
	m.ctrl.T.Helper()
	ret := m.ctrl.Call(m, "ContentUpdate", u, space, ct, c, newParams, updateParams)
	ret := m.ctrl.Call(m, "ContentUpdate", ctx, u, space, ct, c, newParams, updateParams)
	ret0, _ := ret[0].(content.Content)
	ret1, _ := ret[1].(error)
	return ret0, ret1
}

// ContentUpdate indicates an expected call of ContentUpdate
func (mr *MockDBerMockRecorder) ContentUpdate(u, space, ct, content, newParams, updateParams interface{}) *gomock.Call {
func (mr *MockdberMockRecorder) ContentUpdate(ctx, u, space, ct, c, newParams, updateParams interface{}) *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ContentUpdate", reflect.TypeOf((*MockDBer)(nil).ContentUpdate), u, space, ct, content, newParams, updateParams)
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ContentUpdate", reflect.TypeOf((*Mockdber)(nil).ContentUpdate), ctx, u, space, ct, c, newParams, updateParams)
}

// ContentDelete mocks base method
func (m *MockDBer) ContentDelete(u user.User, space space.Space, ct contenttype.ContentType, content content.Content) error {
func (m *Mockdber) ContentDelete(ctx context.Context, u user.User, space space.Space, ct contenttype.ContentType, c content.Content) error {
	m.ctrl.T.Helper()
	ret := m.ctrl.Call(m, "ContentDelete", u, space, ct, content)
	ret := m.ctrl.Call(m, "ContentDelete", ctx, u, space, ct, c)
	ret0, _ := ret[0].(error)
	return ret0
}

// ContentDelete indicates an expected call of ContentDelete
func (mr *MockDBerMockRecorder) ContentDelete(u, space, ct, content interface{}) *gomock.Call {
func (mr *MockdberMockRecorder) ContentDelete(ctx, u, space, ct, c interface{}) *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ContentDelete", reflect.TypeOf((*MockDBer)(nil).ContentDelete), u, space, ct, content)
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ContentDelete", reflect.TypeOf((*Mockdber)(nil).ContentDelete), ctx, u, space, ct, c)
}

// ContentSearch mocks base method
func (m *MockDBer) ContentSearch(u user.User, space space.Space, ct contenttype.ContentType, name, query string, before int) (content.ContentList, error) {
func (m *Mockdber) ContentSearch(ctx context.Context, u user.User, space space.Space, ct contenttype.ContentType, name, query string, before int) (content.ContentList, error) {
	m.ctrl.T.Helper()
	ret := m.ctrl.Call(m, "ContentSearch", u, space, ct, name, query, before)
	ret := m.ctrl.Call(m, "ContentSearch", ctx, u, space, ct, name, query, before)
	ret0, _ := ret[0].(content.ContentList)
	ret1, _ := ret[1].(error)
	return ret0, ret1
}

// ContentSearch indicates an expected call of ContentSearch
func (mr *MockDBerMockRecorder) ContentSearch(u, space, ct, name, query, before interface{}) *gomock.Call {
func (mr *MockdberMockRecorder) ContentSearch(ctx, u, space, ct, name, query, before interface{}) *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ContentSearch", reflect.TypeOf((*MockDBer)(nil).ContentSearch), u, space, ct, name, query, before)
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ContentSearch", reflect.TypeOf((*Mockdber)(nil).ContentSearch), ctx, u, space, ct, name, query, before)
}

// MockE3er is a mock of E3er interface


@@ 237,13 236,13 @@ func (m *MockHooker) EXPECT() *MockHookerMockRecorder {
}

// Do mocks base method
func (m *MockHooker) Do(user user.User, space space.Space, content content.Content, ht hook.HookType) {
func (m *MockHooker) Do(ctx context.Context, user user.User, space space.Space, content content.Content, ht hook.HookType) {
	m.ctrl.T.Helper()
	m.ctrl.Call(m, "Do", user, space, content, ht)
	m.ctrl.Call(m, "Do", ctx, user, space, content, ht)
}

// Do indicates an expected call of Do
func (mr *MockHookerMockRecorder) Do(user, space, content, ht interface{}) *gomock.Call {
func (mr *MockHookerMockRecorder) Do(ctx, user, space, content, ht interface{}) *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Do", reflect.TypeOf((*MockHooker)(nil).Do), user, space, content, ht)
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Do", reflect.TypeOf((*MockHooker)(nil).Do), ctx, user, space, content, ht)
}

M internal/c/content/content_test.go => internal/c/content/content_test.go +101 -98
@@ 28,7 28,10 @@ import (
	"github.com/google/uuid"
)

var file, _ = os.Open("testfiles/zoidberg.png")
var (
	file, _ = os.Open("testfiles/zoidberg.png")
	ctx     = gomock.Any()
)

func bodyWithFile(name string, form url.Values) (io.Reader, string) {
	var requestBody bytes.Buffer


@@ 159,7 162,7 @@ func TestCreateGood(t *testing.T) {
		}

		ctrl = gomock.NewController(t)
		db   = content.NewMockDBer(ctrl)
		db   = content.NewMockdber(ctrl)
		e3   = content.NewMockE3er(ctrl)
		h    = content.NewMockHooker(ctrl)
		l    = log.New(os.Stdout, "", 0)


@@ 179,12 182,12 @@ func TestCreateGood(t *testing.T) {
		}
	)

	db.EXPECT().UserGet(u.Name(), u.Pass()).Return(u, nil).AnyTimes()
	db.EXPECT().SpaceGet(u, s.ID()).Return(s, nil).AnyTimes()
	db.EXPECT().ContentTypeGet(u, s, ct.ID()).Return(ct, nil).AnyTimes()
	db.EXPECT().ContentNew(u, s, ct, nmatcher{newParams}).Return(c, nil).AnyTimes()
	db.EXPECT().UserGet(ctx, u.Name(), u.Pass()).Return(u, nil).AnyTimes()
	db.EXPECT().SpaceGet(ctx, u, s.ID()).Return(s, nil).AnyTimes()
	db.EXPECT().ContentTypeGet(ctx, u, s, ct.ID()).Return(ct, nil).AnyTimes()
	db.EXPECT().ContentNew(ctx, u, s, ct, nmatcher{newParams}).Return(c, nil).AnyTimes()
	e3.EXPECT().Upload(gomock.Any(), false, gomock.Any(), gomock.Any()).Return(fileURL, nil).AnyTimes()
	h.EXPECT().Do(u, s, c, webhook.HookNew).Return().AnyTimes()
	h.EXPECT().Do(ctx, u, s, c, webhook.HookNew).Return().AnyTimes()

	bod, headerCT := bodyWithFile("File-image", form)
	req, _ := http.NewRequest("POST", ts.URL, bod)


@@ 213,7 216,7 @@ func TestUpdateGood(t *testing.T) {
		}

		ctrl = gomock.NewController(t)
		db   = content.NewMockDBer(ctrl)
		db   = content.NewMockdber(ctrl)
		e3   = content.NewMockE3er(ctrl)
		h    = content.NewMockHooker(ctrl)
		l    = log.New(os.Stdout, "", 0)


@@ 236,13 239,13 @@ func TestUpdateGood(t *testing.T) {
		}
	)

	db.EXPECT().UserGet(u.Name(), u.Pass()).Return(u, nil).AnyTimes()
	db.EXPECT().SpaceGet(u, s.ID()).Return(s, nil).AnyTimes()
	db.EXPECT().ContentTypeGet(u, s, ct.ID()).Return(ct, nil).AnyTimes()
	db.EXPECT().ContentGet(u, s, ct, c.ID()).Return(c, nil).AnyTimes()
	db.EXPECT().ContentUpdate(u, s, ct, c, nmatcher{newParams}, umatcher{updateParams}).Return(c, nil).AnyTimes()
	db.EXPECT().UserGet(ctx, u.Name(), u.Pass()).Return(u, nil).AnyTimes()
	db.EXPECT().SpaceGet(ctx, u, s.ID()).Return(s, nil).AnyTimes()
	db.EXPECT().ContentTypeGet(ctx, u, s, ct.ID()).Return(ct, nil).AnyTimes()
	db.EXPECT().ContentGet(ctx, u, s, ct, c.ID()).Return(c, nil).AnyTimes()
	db.EXPECT().ContentUpdate(ctx, u, s, ct, c, nmatcher{newParams}, umatcher{updateParams}).Return(c, nil).AnyTimes()
	e3.EXPECT().Upload(gomock.Any(), false, gomock.Any(), gomock.Any()).Return(fileURL, nil).AnyTimes()
	h.EXPECT().Do(u, s, c, webhook.HookUpdate).Return().AnyTimes()
	h.EXPECT().Do(ctx, u, s, c, webhook.HookUpdate).Return().AnyTimes()

	bod, headerCT := bodyWithFile("File-image", form)
	req, _ := http.NewRequest("POST", ts.URL, bod)


@@ 271,7 274,7 @@ func TestUpdateGood2(t *testing.T) {
		}

		ctrl = gomock.NewController(t)
		db   = content.NewMockDBer(ctrl)
		db   = content.NewMockdber(ctrl)
		e3   = content.NewMockE3er(ctrl)
		h    = content.NewMockHooker(ctrl)
		l    = log.New(os.Stdout, "", 0)


@@ 294,13 297,13 @@ func TestUpdateGood2(t *testing.T) {
		}
	)

	db.EXPECT().UserGet(u.Name(), u.Pass()).Return(u, nil).AnyTimes()
	db.EXPECT().SpaceGet(u, s.ID()).Return(s, nil).AnyTimes()
	db.EXPECT().ContentTypeGet(u, s, ct.ID()).Return(ct, nil).AnyTimes()
	db.EXPECT().ContentGet(u, s, ct, c.ID()).Return(c, nil).AnyTimes()
	db.EXPECT().ContentUpdate(u, s, ct, c, nmatcher{newParams}, umatcher{updateParams}).Return(c, nil).AnyTimes()
	db.EXPECT().UserGet(ctx, u.Name(), u.Pass()).Return(u, nil).AnyTimes()
	db.EXPECT().SpaceGet(ctx, u, s.ID()).Return(s, nil).AnyTimes()
	db.EXPECT().ContentTypeGet(ctx, u, s, ct.ID()).Return(ct, nil).AnyTimes()
	db.EXPECT().ContentGet(ctx, u, s, ct, c.ID()).Return(c, nil).AnyTimes()
	db.EXPECT().ContentUpdate(ctx, u, s, ct, c, nmatcher{newParams}, umatcher{updateParams}).Return(c, nil).AnyTimes()
	e3.EXPECT().Upload(gomock.Any(), false, gomock.Any(), gomock.Any()).Return(fileURL, nil).AnyTimes()
	h.EXPECT().Do(u, s, c, webhook.HookUpdate).Return().AnyTimes()
	h.EXPECT().Do(ctx, u, s, c, webhook.HookUpdate).Return().AnyTimes()

	bod, headerCT := bodyWithFile("value_update_File-4-image", form)
	req, _ := http.NewRequest("POST", ts.URL, bod)


@@ 316,7 319,7 @@ func TestServeGood(t *testing.T) {

	var (
		ctrl = gomock.NewController(t)
		db   = content.NewMockDBer(ctrl)
		db   = content.NewMockdber(ctrl)
		e3   = content.NewMockE3er(ctrl)
		h    = content.NewMockHooker(ctrl)
		l    = log.New(os.Stdout, "", 0)


@@ 335,11 338,11 @@ func TestServeGood(t *testing.T) {
		}
	)

	db.EXPECT().UserGet(u.Name(), u.Pass()).Return(u, nil).AnyTimes()
	db.EXPECT().SpaceGet(u, s.ID()).Return(s, nil).AnyTimes()
	db.EXPECT().ContentTypeGet(u, s, ct.ID()).Return(ct, nil).AnyTimes()
	db.EXPECT().ContentGet(u, s, ct, c.ID()).Return(c, nil).AnyTimes()
	h.EXPECT().Do(u, s, c, webhook.HookNew).Return().AnyTimes()
	db.EXPECT().UserGet(ctx, u.Name(), u.Pass()).Return(u, nil).AnyTimes()
	db.EXPECT().SpaceGet(ctx, u, s.ID()).Return(s, nil).AnyTimes()
	db.EXPECT().ContentTypeGet(ctx, u, s, ct.ID()).Return(ct, nil).AnyTimes()
	db.EXPECT().ContentGet(ctx, u, s, ct, c.ID()).Return(c, nil).AnyTimes()
	h.EXPECT().Do(ctx, u, s, c, webhook.HookNew).Return().AnyTimes()

	req, _ := http.NewRequest("POST", ts.URL,
		strings.NewReader(form.Encode()))


@@ 355,7 358,7 @@ func TestServeGood2(t *testing.T) {

	var (
		ctrl = gomock.NewController(t)
		db   = content.NewMockDBer(ctrl)
		db   = content.NewMockdber(ctrl)
		e3   = content.NewMockE3er(ctrl)
		h    = content.NewMockHooker(ctrl)
		l    = log.New(os.Stdout, "", 0)


@@ 373,11 376,11 @@ func TestServeGood2(t *testing.T) {
		}
	)

	db.EXPECT().UserGet(u.Name(), u.Pass()).Return(u, nil).AnyTimes()
	db.EXPECT().SpaceGet(u, s.ID()).Return(s, nil).AnyTimes()
	db.EXPECT().ContentTypeGet(u, s, ct.ID()).Return(ct, nil).AnyTimes()
	db.EXPECT().ContentGet(u, s, ct, c.ID()).Return(c, nil).AnyTimes()
	h.EXPECT().Do(u, s, c, webhook.HookNew).Return().AnyTimes()
	db.EXPECT().UserGet(ctx, u.Name(), u.Pass()).Return(u, nil).AnyTimes()
	db.EXPECT().SpaceGet(ctx, u, s.ID()).Return(s, nil).AnyTimes()
	db.EXPECT().ContentTypeGet(ctx, u, s, ct.ID()).Return(ct, nil).AnyTimes()
	db.EXPECT().ContentGet(ctx, u, s, ct, c.ID()).Return(c, nil).AnyTimes()
	h.EXPECT().Do(ctx, u, s, c, webhook.HookNew).Return().AnyTimes()

	req, _ := http.NewRequest("GET", ts.URL+"?"+form.Encode(), nil)
	req.SetBasicAuth(u.Name(), u.Pass())


@@ 390,7 393,7 @@ func TestServeGood3(t *testing.T) {

	var (
		ctrl = gomock.NewController(t)
		db   = content.NewMockDBer(ctrl)
		db   = content.NewMockdber(ctrl)
		e3   = content.NewMockE3er(ctrl)
		h    = content.NewMockHooker(ctrl)
		l    = log.New(os.Stdout, "", 0)


@@ 402,11 405,11 @@ func TestServeGood3(t *testing.T) {
		c  = fakecontent{uuid.New().String(), ct.ID(), nil}
	)

	db.EXPECT().UserGet(u.Name(), u.Pass()).Return(u, nil).AnyTimes()
	db.EXPECT().SpaceGet(u, s.ID()).Return(s, nil).AnyTimes()
	db.EXPECT().ContentTypeGet(u, s, ct.ID()).Return(ct, nil).AnyTimes()
	db.EXPECT().ContentGet(u, s, ct, c.ID()).Return(c, nil).AnyTimes()
	h.EXPECT().Do(u, s, c, webhook.HookNew).Return().AnyTimes()
	db.EXPECT().UserGet(ctx, u.Name(), u.Pass()).Return(u, nil).AnyTimes()
	db.EXPECT().SpaceGet(ctx, u, s.ID()).Return(s, nil).AnyTimes()
	db.EXPECT().ContentTypeGet(ctx, u, s, ct.ID()).Return(ct, nil).AnyTimes()
	db.EXPECT().ContentGet(ctx, u, s, ct, c.ID()).Return(c, nil).AnyTimes()
	h.EXPECT().Do(ctx, u, s, c, webhook.HookNew).Return().AnyTimes()

	req, _ := http.NewRequest("GET", fmt.Sprintf("%s/content/%s/%s/%s", ts.URL, s.ID(), ct.ID(), c.ID()), nil)
	req.SetBasicAuth(u.Name(), u.Pass())


@@ 419,7 422,7 @@ func TestDeleteGood(t *testing.T) {

	var (
		ctrl = gomock.NewController(t)
		db   = content.NewMockDBer(ctrl)
		db   = content.NewMockdber(ctrl)
		e3   = content.NewMockE3er(ctrl)
		h    = content.NewMockHooker(ctrl)
		l    = log.New(os.Stdout, "", 0)


@@ 437,12 440,12 @@ func TestDeleteGood(t *testing.T) {
		}
	)

	db.EXPECT().UserGet(u.Name(), u.Pass()).Return(u, nil).AnyTimes()
	db.EXPECT().SpaceGet(u, s.ID()).Return(s, nil).AnyTimes()
	db.EXPECT().ContentTypeGet(u, s, ct.ID()).Return(ct, nil).AnyTimes()
	db.EXPECT().ContentGet(u, s, ct, c.ID()).Return(c, nil).AnyTimes()
	db.EXPECT().ContentDelete(u, s, ct, c).Return(nil).AnyTimes()
	h.EXPECT().Do(u, s, c, webhook.HookDelete).Return().AnyTimes()
	db.EXPECT().UserGet(ctx, u.Name(), u.Pass()).Return(u, nil).AnyTimes()
	db.EXPECT().SpaceGet(ctx, u, s.ID()).Return(s, nil).AnyTimes()
	db.EXPECT().ContentTypeGet(ctx, u, s, ct.ID()).Return(ct, nil).AnyTimes()
	db.EXPECT().ContentGet(ctx, u, s, ct, c.ID()).Return(c, nil).AnyTimes()
	db.EXPECT().ContentDelete(ctx, u, s, ct, c).Return(nil).AnyTimes()
	h.EXPECT().Do(ctx, u, s, c, webhook.HookDelete).Return().AnyTimes()

	req, _ := http.NewRequest("DELETE", ts.URL+"?"+form.Encode(), nil)
	req.Header.Set("Content-Type", "application/x-www-form-urlencoded")


@@ 457,7 460,7 @@ func TestSearchGood(t *testing.T) {

	var (
		ctrl = gomock.NewController(t)
		db   = content.NewMockDBer(ctrl)
		db   = content.NewMockdber(ctrl)
		e3   = content.NewMockE3er(ctrl)
		h    = content.NewMockHooker(ctrl)
		l    = log.New(os.Stdout, "", 0)


@@ 476,10 479,10 @@ func TestSearchGood(t *testing.T) {
		}
	)

	db.EXPECT().UserGet(u.Name(), u.Pass()).Return(u, nil).AnyTimes()
	db.EXPECT().SpaceGet(u, s.ID()).Return(s, nil).AnyTimes()
	db.EXPECT().ContentTypeGet(u, s, ct.ID()).Return(ct, nil).AnyTimes()
	db.EXPECT().ContentSearch(u, s, ct, "name", "garfield", 0).Return(cl, nil).AnyTimes()
	db.EXPECT().UserGet(ctx, u.Name(), u.Pass()).Return(u, nil).AnyTimes()
	db.EXPECT().SpaceGet(ctx, u, s.ID()).Return(s, nil).AnyTimes()
	db.EXPECT().ContentTypeGet(ctx, u, s, ct.ID()).Return(ct, nil).AnyTimes()
	db.EXPECT().ContentSearch(ctx, u, s, ct, "name", "garfield", 0).Return(cl, nil).AnyTimes()

	req, _ := http.NewRequest("GET", ts.URL+"?"+form.Encode(), nil)
	req.SetBasicAuth(u.Name(), u.Pass())


@@ 503,7 506,7 @@ func TestBad(t *testing.T) {
		sc   int
		err  error
		form url.Values
		mock func(*content.MockDBer, *content.MockE3er, *content.MockHooker)
		mock func(*content.Mockdber, *content.MockE3er, *content.MockHooker)
	}

	tests := []spec{


@@ 514,8 517,8 @@ func TestBad(t *testing.T) {
			url.Values{
				"method": {"GET"},
			},
			func(db *content.MockDBer, e3 *content.MockE3er, h *content.MockHooker) {
				db.EXPECT().UserGet(u.Name(), u.Pass()).Return(nil, err).AnyTimes()
			func(db *content.Mockdber, e3 *content.MockE3er, h *content.MockHooker) {
				db.EXPECT().UserGet(ctx, u.Name(), u.Pass()).Return(nil, err).AnyTimes()
			},
		},
		{


@@ 525,8 528,8 @@ func TestBad(t *testing.T) {
				"method": {"GET"},
				"query":  {"placeholder"},
			},
			func(db *content.MockDBer, e3 *content.MockE3er, h *content.MockHooker) {
				db.EXPECT().UserGet(u.Name(), u.Pass()).Return(nil, err).AnyTimes()
			func(db *content.Mockdber, e3 *content.MockE3er, h *content.MockHooker) {
				db.EXPECT().UserGet(ctx, u.Name(), u.Pass()).Return(nil, err).AnyTimes()
			},
		},
		{


@@ 535,8 538,8 @@ func TestBad(t *testing.T) {
			url.Values{
				"method": {"PATCH"},
			},
			func(db *content.MockDBer, e3 *content.MockE3er, h *content.MockHooker) {
				db.EXPECT().UserGet(u.Name(), u.Pass()).Return(nil, err).AnyTimes()
			func(db *content.Mockdber, e3 *content.MockE3er, h *content.MockHooker) {
				db.EXPECT().UserGet(ctx, u.Name(), u.Pass()).Return(nil, err).AnyTimes()
			},
		},
		{


@@ 545,8 548,8 @@ func TestBad(t *testing.T) {
			url.Values{
				"method": {"DELETE"},
			},
			func(db *content.MockDBer, e3 *content.MockE3er, h *content.MockHooker) {
				db.EXPECT().UserGet(u.Name(), u.Pass()).Return(nil, err).AnyTimes()
			func(db *content.Mockdber, e3 *content.MockE3er, h *content.MockHooker) {
				db.EXPECT().UserGet(ctx, u.Name(), u.Pass()).Return(nil, err).AnyTimes()
			},
		},
		{


@@ 555,8 558,8 @@ func TestBad(t *testing.T) {
			url.Values{
				"method": {"POST"},
			},
			func(db *content.MockDBer, e3 *content.MockE3er, h *content.MockHooker) {
				db.EXPECT().UserGet(u.Name(), u.Pass()).Return(nil, err).AnyTimes()
			func(db *content.Mockdber, e3 *content.MockE3er, h *content.MockHooker) {
				db.EXPECT().UserGet(ctx, u.Name(), u.Pass()).Return(nil, err).AnyTimes()
			},
		},
		// No space.


@@ 567,9 570,9 @@ func TestBad(t *testing.T) {
				"method": {"GET"},
				"space":  {s.ID()},
			},
			func(db *content.MockDBer, e3 *content.MockE3er, h *content.MockHooker) {
				db.EXPECT().UserGet(u.Name(), u.Pass()).Return(u, nil).AnyTimes()
				db.EXPECT().SpaceGet(u, s.ID()).Return(nil, err).AnyTimes()
			func(db *content.Mockdber, e3 *content.MockE3er, h *content.MockHooker) {
				db.EXPECT().UserGet(ctx, u.Name(), u.Pass()).Return(u, nil).AnyTimes()
				db.EXPECT().SpaceGet(ctx, u, s.ID()).Return(nil, err).AnyTimes()
			},
		},
		{


@@ 580,9 583,9 @@ func TestBad(t *testing.T) {
				"query":  {"placeholder"},
				"space":  {s.ID()},
			},
			func(db *content.MockDBer, e3 *content.MockE3er, h *content.MockHooker) {
				db.EXPECT().UserGet(u.Name(), u.Pass()).Return(u, nil).AnyTimes()
				db.EXPECT().SpaceGet(u, s.ID()).Return(nil, err).AnyTimes()
			func(db *content.Mockdber, e3 *content.MockE3er, h *content.MockHooker) {
				db.EXPECT().UserGet(ctx, u.Name(), u.Pass()).Return(u, nil).AnyTimes()
				db.EXPECT().SpaceGet(ctx, u, s.ID()).Return(nil, err).AnyTimes()
			},
		},
		{


@@ 592,9 595,9 @@ func TestBad(t *testing.T) {
				"method": {"PATCH"},
				"space":  {s.ID()},
			},
			func(db *content.MockDBer, e3 *content.MockE3er, h *content.MockHooker) {
				db.EXPECT().UserGet(u.Name(), u.Pass()).Return(u, nil).AnyTimes()
				db.EXPECT().SpaceGet(u, s.ID()).Return(nil, err).AnyTimes()
			func(db *content.Mockdber, e3 *content.MockE3er, h *content.MockHooker) {
				db.EXPECT().UserGet(ctx, u.Name(), u.Pass()).Return(u, nil).AnyTimes()
				db.EXPECT().SpaceGet(ctx, u, s.ID()).Return(nil, err).AnyTimes()
			},
		},
		{


@@ 604,9 607,9 @@ func TestBad(t *testing.T) {
				"method": {"DELETE"},
				"space":  {s.ID()},
			},
			func(db *content.MockDBer, e3 *content.MockE3er, h *content.MockHooker) {
				db.EXPECT().UserGet(u.Name(), u.Pass()).Return(u, nil).AnyTimes()
				db.EXPECT().SpaceGet(u, s.ID()).Return(nil, err).AnyTimes()
			func(db *content.Mockdber, e3 *content.MockE3er, h *content.MockHooker) {
				db.EXPECT().UserGet(ctx, u.Name(), u.Pass()).Return(u, nil).AnyTimes()
				db.EXPECT().SpaceGet(ctx, u, s.ID()).Return(nil, err).AnyTimes()
			},
		},
		{


@@ 616,9 619,9 @@ func TestBad(t *testing.T) {
				"method": {"POST"},
				"space":  {s.ID()},
			},
			func(db *content.MockDBer, e3 *content.MockE3er, h *content.MockHooker) {
				db.EXPECT().UserGet(u.Name(), u.Pass()).Return(u, nil).AnyTimes()
				db.EXPECT().SpaceGet(u, s.ID()).Return(nil, err).AnyTimes()
			func(db *content.Mockdber, e3 *content.MockE3er, h *content.MockHooker) {
				db.EXPECT().UserGet(ctx, u.Name(), u.Pass()).Return(u, nil).AnyTimes()
				db.EXPECT().SpaceGet(ctx, u, s.ID()).Return(nil, err).AnyTimes()
			},
		},
		// No content type


@@ 630,10 633,10 @@ func TestBad(t *testing.T) {
				"space":       {s.ID()},
				"contenttype": {ct.ID()},
			},
			func(db *content.MockDBer, e3 *content.MockE3er, h *content.MockHooker) {
				db.EXPECT().UserGet(u.Name(), u.Pass()).Return(u, nil).AnyTimes()
				db.EXPECT().SpaceGet(u, s.ID()).Return(s, nil).AnyTimes()
				db.EXPECT().ContentTypeGet(u, s, ct.ID()).Return(nil, err).AnyTimes()
			func(db *content.Mockdber, e3 *content.MockE3er, h *content.MockHooker) {
				db.EXPECT().UserGet(ctx, u.Name(), u.Pass()).Return(u, nil).AnyTimes()
				db.EXPECT().SpaceGet(ctx, u, s.ID()).Return(s, nil).AnyTimes()
				db.EXPECT().ContentTypeGet(ctx, u, s, ct.ID()).Return(nil, err).AnyTimes()
			},
		},
		{


@@ 645,10 648,10 @@ func TestBad(t *testing.T) {
				"space":       {s.ID()},
				"contenttype": {ct.ID()},
			},
			func(db *content.MockDBer, e3 *content.MockE3er, h *content.MockHooker) {
				db.EXPECT().UserGet(u.Name(), u.Pass()).Return(u, nil).AnyTimes()
				db.EXPECT().SpaceGet(u, s.ID()).Return(s, nil).AnyTimes()
				db.EXPECT().ContentTypeGet(u, s, ct.ID()).Return(nil, err).AnyTimes()
			func(db *content.Mockdber, e3 *content.MockE3er, h *content.MockHooker) {
				db.EXPECT().UserGet(ctx, u.Name(), u.Pass()).Return(u, nil).AnyTimes()
				db.EXPECT().SpaceGet(ctx, u, s.ID()).Return(s, nil).AnyTimes()
				db.EXPECT().ContentTypeGet(ctx, u, s, ct.ID()).Return(nil, err).AnyTimes()
			},
		},
		{


@@ 659,10 662,10 @@ func TestBad(t *testing.T) {
				"space":       {s.ID()},
				"contenttype": {ct.ID()},
			},
			func(db *content.MockDBer, e3 *content.MockE3er, h *content.MockHooker) {
				db.EXPECT().UserGet(u.Name(), u.Pass()).Return(u, nil).AnyTimes()
				db.EXPECT().SpaceGet(u, s.ID()).Return(s, nil).AnyTimes()
				db.EXPECT().ContentTypeGet(u, s, ct.ID()).Return(nil, err).AnyTimes()
			func(db *content.Mockdber, e3 *content.MockE3er, h *content.MockHooker) {
				db.EXPECT().UserGet(ctx, u.Name(), u.Pass()).Return(u, nil).AnyTimes()
				db.EXPECT().SpaceGet(ctx, u, s.ID()).Return(s, nil).AnyTimes()
				db.EXPECT().ContentTypeGet(ctx, u, s, ct.ID()).Return(nil, err).AnyTimes()
			},
		},
		{


@@ 673,10 676,10 @@ func TestBad(t *testing.T) {
				"space":       {s.ID()},
				"contenttype": {ct.ID()},
			},
			func(db *content.MockDBer, e3 *content.MockE3er, h *content.MockHooker) {
				db.EXPECT().UserGet(u.Name(), u.Pass()).Return(u, nil).AnyTimes()
				db.EXPECT().SpaceGet(u, s.ID()).Return(s, nil).AnyTimes()
				db.EXPECT().ContentTypeGet(u, s, ct.ID()).Return(nil, err).AnyTimes()
			func(db *content.Mockdber, e3 *content.MockE3er, h *content.MockHooker) {
				db.EXPECT().UserGet(ctx, u.Name(), u.Pass()).Return(u, nil).AnyTimes()
				db.EXPECT().SpaceGet(ctx, u, s.ID()).Return(s, nil).AnyTimes()
				db.EXPECT().ContentTypeGet(ctx, u, s, ct.ID()).Return(nil, err).AnyTimes()
			},
		},
		{


@@ 687,10 690,10 @@ func TestBad(t *testing.T) {
				"space":       {s.ID()},
				"contenttype": {ct.ID()},
			},
			func(db *content.MockDBer, e3 *content.MockE3er, h *content.MockHooker) {
				db.EXPECT().UserGet(u.Name(), u.Pass()).Return(u, nil).AnyTimes()
				db.EXPECT().SpaceGet(u, s.ID()).Return(s, nil).AnyTimes()
				db.EXPECT().ContentTypeGet(u, s, ct.ID()).Return(nil, err).AnyTimes()
			func(db *content.Mockdber, e3 *content.MockE3er, h *content.MockHooker) {
				db.EXPECT().UserGet(ctx, u.Name(), u.Pass()).Return(u, nil).AnyTimes()
				db.EXPECT().SpaceGet(ctx, u, s.ID()).Return(s, nil).AnyTimes()
				db.EXPECT().ContentTypeGet(ctx, u, s, ct.ID()).Return(nil, err).AnyTimes()
			},
		},
	}


@@ 698,7 701,7 @@ func TestBad(t *testing.T) {
	for _, test := range tests {
		var (
			ctrl = gomock.NewController(t)
			db   = content.NewMockDBer(ctrl)
			db   = content.NewMockdber(ctrl)
			e3   = content.NewMockE3er(ctrl)
			h    = content.NewMockHooker(ctrl)
			l    = log.New(os.Stdout, "", 0)

M internal/c/contenttype/contenttype.go => internal/c/contenttype/contenttype.go +1 -1
@@ 46,7 46,7 @@ type dber interface {
	SpaceGet(ctx context.Context, user user.User, spaceID string) (space.Space, error)
	ContentTypeNew(ctx context.Context, user user.User, space space.Space, name string, params []db.ContentTypeNewParam) (contenttype.ContentType, error)
	ContentTypeGet(ctx context.Context, user user.User, space space.Space, contenttypeID string) (contenttype.ContentType, error)
	ContentTypeUpdate(ctx context.Context, user user.User, space space.Space, contenttype contenttype.ContentType, name string, newParams []db.ContentTypeNewParam, updateParams []db.ContentTypeUpdateParam) (contenttype.ContentType, error)
	ContentTypeUpdate(ctx context.Context, user user.User, space space.Space, ct contenttype.ContentType, name string, newParams []db.ContentTypeNewParam, updateParams []db.ContentTypeUpdateParam) (contenttype.ContentType, error)
	ContentTypeDelete(ctx context.Context, user user.User, space space.Space, ct contenttype.ContentType) error
	ContentTypeSearch(ctx context.Context, user user.User, space space.Space, query string, before int) (contenttype.ContentTypeList, error)
	ContentPerContentType(ctx context.Context, user user.User, space space.Space, ct contenttype.ContentType, before int, order db.OrderType, sortField string) (content.ContentList, error)

M internal/c/contenttype/contenttype_mock.go => internal/c/contenttype/contenttype_mock.go +38 -38
@@ 5,14 5,14 @@
package contenttype

import (
	reflect "reflect"

	context "context"
	content "git.sr.ht/~evanj/cms/internal/m/content"
	contenttype "git.sr.ht/~evanj/cms/internal/m/contenttype"
	space "git.sr.ht/~evanj/cms/internal/m/space"
	user "git.sr.ht/~evanj/cms/internal/m/user"
	db "git.sr.ht/~evanj/cms/internal/s/db"
	gomock "github.com/golang/mock/gomock"
	reflect "reflect"
)

// Mockdber is a mock of dber interface


@@ 39,135 39,135 @@ func (m *Mockdber) EXPECT() *MockdberMockRecorder {
}

// UserGet mocks base method
func (m *Mockdber) UserGet(username, password string) (user.User, error) {
func (m *Mockdber) UserGet(ctx context.Context, username, password string) (user.User, error) {
	m.ctrl.T.Helper()
	ret := m.ctrl.Call(m, "UserGet", username, password)
	ret := m.ctrl.Call(m, "UserGet", ctx, username, password)
	ret0, _ := ret[0].(user.User)
	ret1, _ := ret[1].(error)
	return ret0, ret1
}

// UserGet indicates an expected call of UserGet
func (mr *MockdberMockRecorder) UserGet(username, password interface{}) *gomock.Call {
func (mr *MockdberMockRecorder) UserGet(ctx, username, password interface{}) *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UserGet", reflect.TypeOf((*Mockdber)(nil).UserGet), username, password)
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UserGet", reflect.TypeOf((*Mockdber)(nil).UserGet), ctx, username, password)
}

// UserGetFromToken mocks base method
func (m *Mockdber) UserGetFromToken(token string) (user.User, error) {
func (m *Mockdber) UserGetFromToken(ctx context.Context, token string) (user.User, error) {
	m.ctrl.T.Helper()
	ret := m.ctrl.Call(m, "UserGetFromToken", token)
	ret := m.ctrl.Call(m, "UserGetFromToken", ctx, token)
	ret0, _ := ret[0].(user.User)
	ret1, _ := ret[1].(error)
	return ret0, ret1
}

// UserGetFromToken indicates an expected call of UserGetFromToken
func (mr *MockdberMockRecorder) UserGetFromToken(token interface{}) *gomock.Call {
func (mr *MockdberMockRecorder) UserGetFromToken(ctx, token interface{}) *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UserGetFromToken", reflect.TypeOf((*Mockdber)(nil).UserGetFromToken), token)
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UserGetFromToken", reflect.TypeOf((*Mockdber)(nil).UserGetFromToken), ctx, token)
}

// SpaceGet mocks base method
func (m *Mockdber) SpaceGet(user user.User, spaceID string) (space.Space, error) {
func (m *Mockdber) SpaceGet(ctx context.Context, user user.User, spaceID string) (space.Space, error) {
	m.ctrl.T.Helper()
	ret := m.ctrl.Call(m, "SpaceGet", user, spaceID)
	ret := m.ctrl.Call(m, "SpaceGet", ctx, user, spaceID)
	ret0, _ := ret[0].(space.Space)
	ret1, _ := ret[1].(error)
	return ret0, ret1
}

// SpaceGet indicates an expected call of SpaceGet
func (mr *MockdberMockRecorder) SpaceGet(user, spaceID interface{}) *gomock.Call {
func (mr *MockdberMockRecorder) SpaceGet(ctx, user, spaceID interface{}) *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SpaceGet", reflect.TypeOf((*Mockdber)(nil).SpaceGet), user, spaceID)
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SpaceGet", reflect.TypeOf((*Mockdber)(nil).SpaceGet), ctx, user, spaceID)
}

// ContentTypeNew mocks base method
func (m *Mockdber) ContentTypeNew(user user.User, space space.Space, name string, params []db.ContentTypeNewParam) (contenttype.ContentType, error) {
func (m *Mockdber) ContentTypeNew(ctx context.Context, user user.User, space space.Space, name string, params []db.ContentTypeNewParam) (contenttype.ContentType, error) {
	m.ctrl.T.Helper()
	ret := m.ctrl.Call(m, "ContentTypeNew", user, space, name, params)
	ret := m.ctrl.Call(m, "ContentTypeNew", ctx, user, space, name, params)
	ret0, _ := ret[0].(contenttype.ContentType)
	ret1, _ := ret[1].(error)
	return ret0, ret1
}

// ContentTypeNew indicates an expected call of ContentTypeNew
func (mr *MockdberMockRecorder) ContentTypeNew(user, space, name, params interface{}) *gomock.Call {
func (mr *MockdberMockRecorder) ContentTypeNew(ctx, user, space, name, params interface{}) *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ContentTypeNew", reflect.TypeOf((*Mockdber)(nil).ContentTypeNew), user, space, name, params)
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ContentTypeNew", reflect.TypeOf((*Mockdber)(nil).ContentTypeNew), ctx, user, space, name, params)
}

// ContentTypeGet mocks base method
func (m *Mockdber) ContentTypeGet(user user.User, space space.Space, contenttypeID string) (contenttype.ContentType, error) {
func (m *Mockdber) ContentTypeGet(ctx context.Context, user user.User, space space.Space, contenttypeID string) (contenttype.ContentType, error) {
	m.ctrl.T.Helper()
	ret := m.ctrl.Call(m, "ContentTypeGet", user, space, contenttypeID)
	ret := m.ctrl.Call(m, "ContentTypeGet", ctx, user, space, contenttypeID)
	ret0, _ := ret[0].(contenttype.ContentType)
	ret1, _ := ret[1].(error)
	return ret0, ret1
}

// ContentTypeGet indicates an expected call of ContentTypeGet
func (mr *MockdberMockRecorder) ContentTypeGet(user, space, contenttypeID interface{}) *gomock.Call {
func (mr *MockdberMockRecorder) ContentTypeGet(ctx, user, space, contenttypeID interface{}) *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ContentTypeGet", reflect.TypeOf((*Mockdber)(nil).ContentTypeGet), user, space, contenttypeID)
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ContentTypeGet", reflect.TypeOf((*Mockdber)(nil).ContentTypeGet), ctx, user, space, contenttypeID)
}

// ContentTypeUpdate mocks base method
func (m *Mockdber) ContentTypeUpdate(user user.User, space space.Space, ct contenttype.ContentType, name string, newParams []db.ContentTypeNewParam, updateParams []db.ContentTypeUpdateParam) (contenttype.ContentType, error) {
func (m *Mockdber) ContentTypeUpdate(ctx context.Context, user user.User, space space.Space, ct contenttype.ContentType, name string, newParams []db.ContentTypeNewParam, updateParams []db.ContentTypeUpdateParam) (contenttype.ContentType, error) {
	m.ctrl.T.Helper()
	ret := m.ctrl.Call(m, "ContentTypeUpdate", user, space, ct, name, newParams, updateParams)
	ret := m.ctrl.Call(m, "ContentTypeUpdate", ctx, user, space, ct, name, newParams, updateParams)
	ret0, _ := ret[0].(contenttype.ContentType)
	ret1, _ := ret[1].(error)
	return ret0, ret1
}

// ContentTypeUpdate indicates an expected call of ContentTypeUpdate
func (mr *MockdberMockRecorder) ContentTypeUpdate(user, space, contenttype, name, newParams, updateParams interface{}) *gomock.Call {
func (mr *MockdberMockRecorder) ContentTypeUpdate(ctx, user, space, ct, name, newParams, updateParams interface{}) *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ContentTypeUpdate", reflect.TypeOf((*Mockdber)(nil).ContentTypeUpdate), user, space, contenttype, name, newParams, updateParams)
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ContentTypeUpdate", reflect.TypeOf((*Mockdber)(nil).ContentTypeUpdate), ctx, user, space, ct, name, newParams, updateParams)
}

// ContentTypeDelete mocks base method
func (m *Mockdber) ContentTypeDelete(user user.User, space space.Space, ct contenttype.ContentType) error {
func (m *Mockdber) ContentTypeDelete(ctx context.Context, user user.User, space space.Space, ct contenttype.ContentType) error {
	m.ctrl.T.Helper()
	ret := m.ctrl.Call(m, "ContentTypeDelete", user, space, ct)
	ret := m.ctrl.Call(m, "ContentTypeDelete", ctx, user, space, ct)
	ret0, _ := ret[0].(error)
	return ret0
}

// ContentTypeDelete indicates an expected call of ContentTypeDelete
func (mr *MockdberMockRecorder) ContentTypeDelete(user, space, ct interface{}) *gomock.Call {
func (mr *MockdberMockRecorder) ContentTypeDelete(ctx, user, space, ct interface{}) *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ContentTypeDelete", reflect.TypeOf((*Mockdber)(nil).ContentTypeDelete), user, space, ct)
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ContentTypeDelete", reflect.TypeOf((*Mockdber)(nil).ContentTypeDelete), ctx, user, space, ct)
}

// ContentTypeSearch mocks base method
func (m *Mockdber) ContentTypeSearch(user user.User, space space.Space, query string, before int) (contenttype.ContentTypeList, error) {
func (m *Mockdber) ContentTypeSearch(ctx context.Context, user user.User, space space.Space, query string, before int) (contenttype.ContentTypeList, error) {
	m.ctrl.T.Helper()
	ret := m.ctrl.Call(m, "ContentTypeSearch", user, space, query, before)
	ret := m.ctrl.Call(m, "ContentTypeSearch", ctx, user, space, query, before)
	ret0, _ := ret[0].(contenttype.ContentTypeList)
	ret1, _ := ret[1].(error)
	return ret0, ret1
}

// ContentTypeSearch indicates an expected call of ContentTypeSearch
func (mr *MockdberMockRecorder) ContentTypeSearch(user, space, query, before interface{}) *gomock.Call {
func (mr *MockdberMockRecorder) ContentTypeSearch(ctx, user, space, query, before interface{}) *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ContentTypeSearch", reflect.TypeOf((*Mockdber)(nil).ContentTypeSearch), user, space, query, before)
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ContentTypeSearch", reflect.TypeOf((*Mockdber)(nil).ContentTypeSearch), ctx, user, space, query, before)
}

// ContentPerContentType mocks base method
func (m *Mockdber) ContentPerContentType(user user.User, space space.Space, ct contenttype.ContentType, before int, order db.OrderType, sortField string) (content.ContentList, error) {
func (m *Mockdber) ContentPerContentType(ctx context.Context, user user.User, space space.Space, ct contenttype.ContentType, before int, order db.OrderType, sortField string) (content.ContentList, error) {
	m.ctrl.T.Helper()
	ret := m.ctrl.Call(m, "ContentPerContentType", user, space, ct, before, order, sortField)
	ret := m.ctrl.Call(m, "ContentPerContentType", ctx, user, space, ct, before, order, sortField)
	ret0, _ := ret[0].(content.ContentList)
	ret1, _ := ret[1].(error)
	return ret0, ret1
}

// ContentPerContentType indicates an expected call of ContentPerContentType
func (mr *MockdberMockRecorder) ContentPerContentType(user, space, ct, before, order, sortField interface{}) *gomock.Call {
func (mr *MockdberMockRecorder) ContentPerContentType(ctx, user, space, ct, before, order, sortField interface{}) *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ContentPerContentType", reflect.TypeOf((*Mockdber)(nil).ContentPerContentType), user, space, ct, before, order, sortField)
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ContentPerContentType", reflect.TypeOf((*Mockdber)(nil).ContentPerContentType), ctx, user, space, ct, before, order, sortField)
}

M internal/c/contenttype/contenttype_test.go => internal/c/contenttype/contenttype_test.go +45 -43
@@ 22,6 22,8 @@ import (
	"github.com/google/uuid"
)

var ctx = gomock.Any()

func TestNoUser(t *testing.T) {
	t.Parallel()



@@ 91,9 93,9 @@ func TestContentTypeHappyPath(t *testing.T) {
				newParams := []db.ContentTypeNewParam{
					{"name", string(valuetype.StringSmall)},
				}
				m.EXPECT().UserGet(uItem.Name(), uItem.Pass()).Return(uItem, nil).AnyTimes()
				m.EXPECT().SpaceGet(uItem, sItem.ID()).Return(sItem, nil).AnyTimes()
				m.EXPECT().ContentTypeNew(uItem, sItem, ctItem.Name(), newParams).Return(ctItem, nil).AnyTimes()
				m.EXPECT().UserGet(ctx, uItem.Name(), uItem.Pass()).Return(uItem, nil).AnyTimes()
				m.EXPECT().SpaceGet(ctx, uItem, sItem.ID()).Return(sItem, nil).AnyTimes()
				m.EXPECT().ContentTypeNew(ctx, uItem, sItem, ctItem.Name(), newParams).Return(ctItem, nil).AnyTimes()
			},
		},
		{


@@ 116,10 118,10 @@ func TestContentTypeHappyPath(t *testing.T) {
				updateParams := []db.ContentTypeUpdateParam{
					{"1234", "desc", string(valuetype.StringBig)},
				}
				m.EXPECT().UserGet(uItem.Name(), uItem.Pass()).Return(uItem, nil).AnyTimes()
				m.EXPECT().SpaceGet(uItem, sItem.ID()).Return(sItem, nil).AnyTimes()
				m.EXPECT().ContentTypeUpdate(uItem, sItem, ctItemUpdate, ctItemUpdate.Name(), newParams, updateParams).Return(ctItemUpdate, nil).AnyTimes()
				m.EXPECT().ContentTypeGet(uItem, sItem, ctItemUpdate.ID()).Return(ctItemUpdate, nil).AnyTimes()
				m.EXPECT().UserGet(ctx, uItem.Name(), uItem.Pass()).Return(uItem, nil).AnyTimes()
				m.EXPECT().SpaceGet(ctx, uItem, sItem.ID()).Return(sItem, nil).AnyTimes()
				m.EXPECT().ContentTypeUpdate(ctx, uItem, sItem, ctItemUpdate, ctItemUpdate.Name(), newParams, updateParams).Return(ctItemUpdate, nil).AnyTimes()
				m.EXPECT().ContentTypeGet(ctx, uItem, sItem, ctItemUpdate.ID()).Return(ctItemUpdate, nil).AnyTimes()
			},
		},
		{


@@ 130,10 132,10 @@ func TestContentTypeHappyPath(t *testing.T) {
				"method":      {"GET"}, // By default net/http doesn't parse body on DELETE.
			},
			func(m *contenttype.Mockdber) {
				m.EXPECT().UserGet(uItem.Name(), uItem.Pass()).Return(uItem, nil).AnyTimes()
				m.EXPECT().SpaceGet(uItem, sItem.ID()).Return(sItem, nil).AnyTimes()
				m.EXPECT().ContentTypeGet(uItem, sItem, ctItem.ID()).Return(ctItem, nil).AnyTimes()
				m.EXPECT().ContentPerContentType(uItem, sItem, ctItem, 0, db.OrderAsc, "name").Return(cl, nil).AnyTimes()
				m.EXPECT().UserGet(ctx, uItem.Name(), uItem.Pass()).Return(uItem, nil).AnyTimes()
				m.EXPECT().SpaceGet(ctx, uItem, sItem.ID()).Return(sItem, nil).AnyTimes()
				m.EXPECT().ContentTypeGet(ctx, uItem, sItem, ctItem.ID()).Return(ctItem, nil).AnyTimes()
				m.EXPECT().ContentPerContentType(ctx, uItem, sItem, ctItem, 0, db.OrderAsc, "name").Return(cl, nil).AnyTimes()
			},
		},
		{


@@ 144,10 146,10 @@ func TestContentTypeHappyPath(t *testing.T) {
				"method": {"GET"}, // By default net/http doesn't parse body on DELETE.
			},
			func(m *contenttype.Mockdber) {
				m.EXPECT().UserGet(uItem.Name(), uItem.Pass()).Return(uItem, nil).AnyTimes()
				m.EXPECT().SpaceGet(uItem, sItem.ID()).Return(sItem, nil).AnyTimes()
				m.EXPECT().ContentTypeGet(uItem, sItem, ctItem.ID()).Return(ctItem, nil).AnyTimes()
				m.EXPECT().ContentTypeSearch(uItem, sItem, "post", 0).Return(ctl, nil).AnyTimes()
				m.EXPECT().UserGet(ctx, uItem.Name(), uItem.Pass()).Return(uItem, nil).AnyTimes()
				m.EXPECT().SpaceGet(ctx, uItem, sItem.ID()).Return(sItem, nil).AnyTimes()
				m.EXPECT().ContentTypeGet(ctx, uItem, sItem, ctItem.ID()).Return(ctItem, nil).AnyTimes()
				m.EXPECT().ContentTypeSearch(ctx, uItem, sItem, "post", 0).Return(ctl, nil).AnyTimes()
			},
		},
		{


@@ 159,10 161,10 @@ func TestContentTypeHappyPath(t *testing.T) {
				"method":      {"GET"}, // By default net/http doesn't parse body on DELETE.
			},
			func(m *contenttype.Mockdber) {
				m.EXPECT().UserGet(uItem.Name(), uItem.Pass()).Return(uItem, nil).AnyTimes()
				m.EXPECT().SpaceGet(uItem, sItem.ID()).Return(sItem, nil).AnyTimes()
				m.EXPECT().ContentTypeGet(uItem, sItem, ctItem.ID()).Return(ctItem, nil).AnyTimes()
				m.EXPECT().ContentPerContentType(uItem, sItem, ctItem, 0, db.OrderDesc, "name").Return(cl, nil).AnyTimes()
				m.EXPECT().UserGet(ctx, uItem.Name(), uItem.Pass()).Return(uItem, nil).AnyTimes()
				m.EXPECT().SpaceGet(ctx, uItem, sItem.ID()).Return(sItem, nil).AnyTimes()
				m.EXPECT().ContentTypeGet(ctx, uItem, sItem, ctItem.ID()).Return(ctItem, nil).AnyTimes()
				m.EXPECT().ContentPerContentType(ctx, uItem, sItem, ctItem, 0, db.OrderDesc, "name").Return(cl, nil).AnyTimes()
			},
		},
		{


@@ 173,10 175,10 @@ func TestContentTypeHappyPath(t *testing.T) {
				"method":      {"DELETE"}, // By default net/http doesn't parse body on DELETE.
			},
			func(m *contenttype.Mockdber) {
				m.EXPECT().UserGet(uItem.Name(), uItem.Pass()).Return(uItem, nil).AnyTimes()
				m.EXPECT().SpaceGet(uItem, sItem.ID()).Return(sItem, nil).AnyTimes()
				m.EXPECT().ContentTypeGet(uItem, sItem, ctItem.ID()).Return(ctItem, nil).AnyTimes()
				m.EXPECT().ContentTypeDelete(uItem, sItem, ctItem).Return(nil).AnyTimes()
				m.EXPECT().UserGet(ctx, uItem.Name(), uItem.Pass()).Return(uItem, nil).AnyTimes()
				m.EXPECT().SpaceGet(ctx, uItem, sItem.ID()).Return(sItem, nil).AnyTimes()
				m.EXPECT().ContentTypeGet(ctx, uItem, sItem, ctItem.ID()).Return(ctItem, nil).AnyTimes()
				m.EXPECT().ContentTypeDelete(ctx, uItem, sItem, ctItem).Return(nil).AnyTimes()
			},
		},
	}


@@ 238,9 240,9 @@ func TestContentTypeBadPath(t *testing.T) {
				newParams := []db.ContentTypeNewParam{
					{"name", string(valuetype.StringSmall)},
				}
				m.EXPECT().UserGet(uItem.Name(), uItem.Pass()).Return(uItem, nil).AnyTimes()
				m.EXPECT().SpaceGet(uItem, sItem.ID()).Return(sItem, nil).AnyTimes()
				m.EXPECT().ContentTypeNew(uItem, sItem, ctItem.Name(), newParams).Return(ctItem, nil).AnyTimes()
				m.EXPECT().UserGet(ctx, uItem.Name(), uItem.Pass()).Return(uItem, nil).AnyTimes()
				m.EXPECT().SpaceGet(ctx, uItem, sItem.ID()).Return(sItem, nil).AnyTimes()
				m.EXPECT().ContentTypeNew(ctx, uItem, sItem, ctItem.Name(), newParams).Return(ctItem, nil).AnyTimes()
			},
		},
		{


@@ 257,9 259,9 @@ func TestContentTypeBadPath(t *testing.T) {
				newParams := []db.ContentTypeNewParam{
					{"name", string(valuetype.StringSmall)},
				}
				m.EXPECT().UserGet(uItem.Name(), uItem.Pass()).Return(uItem, nil).AnyTimes()
				m.EXPECT().SpaceGet(uItem, sItem.ID()).Return(sItem, nil).AnyTimes()
				m.EXPECT().ContentTypeNew(uItem, sItem, ctItem.Name(), newParams).Return(ctItem, nil).AnyTimes()
				m.EXPECT().UserGet(ctx, uItem.Name(), uItem.Pass()).Return(uItem, nil).AnyTimes()
				m.EXPECT().SpaceGet(ctx, uItem, sItem.ID()).Return(sItem, nil).AnyTimes()
				m.EXPECT().ContentTypeNew(ctx, uItem, sItem, ctItem.Name(), newParams).Return(ctItem, nil).AnyTimes()
			},
		},
		{


@@ 276,9 278,9 @@ func TestContentTypeBadPath(t *testing.T) {
				newParams := []db.ContentTypeNewParam{
					{"name", string(valuetype.StringSmall)},
				}
				m.EXPECT().UserGet(uItem.Name(), uItem.Pass()).Return(uItem, nil).AnyTimes()
				m.EXPECT().SpaceGet(uItem, sItem.ID()).Return(sItem, nil).AnyTimes()
				m.EXPECT().ContentTypeNew(uItem, sItem, ctItem.Name(), newParams).Return(ctItem, nil).AnyTimes()
				m.EXPECT().UserGet(ctx, uItem.Name(), uItem.Pass()).Return(uItem, nil).AnyTimes()
				m.EXPECT().SpaceGet(ctx, uItem, sItem.ID()).Return(sItem, nil).AnyTimes()
				m.EXPECT().ContentTypeNew(ctx, uItem, sItem, ctItem.Name(), newParams).Return(ctItem, nil).AnyTimes()
			},
		},
		{


@@ 295,9 297,9 @@ func TestContentTypeBadPath(t *testing.T) {
				newParams := []db.ContentTypeNewParam{
					{"name", string(valuetype.StringSmall)},
				}
				m.EXPECT().UserGet(uItem.Name(), uItem.Pass()).Return(uItem, nil).AnyTimes()
				m.EXPECT().SpaceGet(uItem, sItem.ID()).Return(sItem, nil).AnyTimes()
				m.EXPECT().ContentTypeNew(uItem, sItem, ctItem.Name(), newParams).Return(nil, err).AnyTimes()
				m.EXPECT().UserGet(ctx, uItem.Name(), uItem.Pass()).Return(uItem, nil).AnyTimes()
				m.EXPECT().SpaceGet(ctx, uItem, sItem.ID()).Return(sItem, nil).AnyTimes()
				m.EXPECT().ContentTypeNew(ctx, uItem, sItem, ctItem.Name(), newParams).Return(nil, err).AnyTimes()
			},
		},
		{


@@ 321,10 323,10 @@ func TestContentTypeBadPath(t *testing.T) {
				updateParams := []db.ContentTypeUpdateParam{
					{"1234", "desc", string(valuetype.StringBig)},
				}
				m.EXPECT().UserGet(uItem.Name(), uItem.Pass()).Return(uItem, nil).AnyTimes()
				m.EXPECT().SpaceGet(uItem, sItem.ID()).Return(sItem, nil).AnyTimes()
				m.EXPECT().ContentTypeUpdate(uItem, sItem, ctItemUpdate, ctItemUpdate.Name(), newParams, updateParams).Return(ctItemUpdate, nil).AnyTimes()
				m.EXPECT().ContentTypeGet(uItem, sItem, ctItemUpdate.ID()).Return(ctItemUpdate, nil).AnyTimes()
				m.EXPECT().UserGet(ctx, uItem.Name(), uItem.Pass()).Return(uItem, nil).AnyTimes()
				m.EXPECT().SpaceGet(ctx, uItem, sItem.ID()).Return(sItem, nil).AnyTimes()
				m.EXPECT().ContentTypeUpdate(ctx, uItem, sItem, ctItemUpdate, ctItemUpdate.Name(), newParams, updateParams).Return(ctItemUpdate, nil).AnyTimes()
				m.EXPECT().ContentTypeGet(ctx, uItem, sItem, ctItemUpdate.ID()).Return(ctItemUpdate, nil).AnyTimes()
			},
		},
		{


@@ 348,10 350,10 @@ func TestContentTypeBadPath(t *testing.T) {
				updateParams := []db.ContentTypeUpdateParam{
					{"1234", "desc", string(valuetype.StringBig)},
				}
				m.EXPECT().UserGet(uItem.Name(), uItem.Pass()).Return(uItem, nil).AnyTimes()
				m.EXPECT().SpaceGet(uItem, sItem.ID()).Return(sItem, nil).AnyTimes()
				m.EXPECT().ContentTypeUpdate(uItem, sItem, ctItemUpdate, ctItemUpdate.Name(), newParams, updateParams).Return(ctItemUpdate, nil).AnyTimes()
				m.EXPECT().ContentTypeGet(uItem, sItem, ctItemUpdate.ID()).Return(ctItemUpdate, nil).AnyTimes()
				m.EXPECT().UserGet(ctx, uItem.Name(), uItem.Pass()).Return(uItem, nil).AnyTimes()
				m.EXPECT().SpaceGet(ctx, uItem, sItem.ID()).Return(sItem, nil).AnyTimes()
				m.EXPECT().ContentTypeUpdate(ctx, uItem, sItem, ctItemUpdate, ctItemUpdate.Name(), newParams, updateParams).Return(ctItemUpdate, nil).AnyTimes()
				m.EXPECT().ContentTypeGet(ctx, uItem, sItem, ctItemUpdate.ID()).Return(ctItemUpdate, nil).AnyTimes()
			},
		},
	}

M internal/c/doc/doc.go => internal/c/doc/doc.go +7 -0
@@ 1,12 1,14 @@
package doc

import (
	"context"
	"html/template"
	"log"
	"net/http"

	"git.sr.ht/~evanj/cms/internal/c"
	"git.sr.ht/~evanj/cms/internal/m/tier"
	"git.sr.ht/~evanj/cms/internal/m/user"
	"git.sr.ht/~evanj/cms/internal/v"
)



@@ 26,6 28,11 @@ type Doc struct {
	log *log.Logger
}

type dber interface {
	UserGet(ctx context.Context, username, password string) (user.User, error)
	UserGetFromToken(ctx context.Context, token string) (user.User, error)
}

func New(c *c.Controller, log *log.Logger) *Doc {
	return &Doc{c, log}
}

R internal/c/doc/mock.go => internal/c/doc/doc_mock.go +9 -8
@@ 5,6 5,7 @@
package doc

import (
	context "context"
	user "git.sr.ht/~evanj/cms/internal/m/user"
	gomock "github.com/golang/mock/gomock"
	reflect "reflect"


@@ 34,31 35,31 @@ func (m *Mockdber) EXPECT() *MockdberMockRecorder {
}

// UserGet mocks base method
func (m *Mockdber) UserGet(username, password string) (user.User, error) {
func (m *Mockdber) UserGet(ctx context.Context, username, password string) (user.User, error) {
	m.ctrl.T.Helper()
	ret := m.ctrl.Call(m, "UserGet", username, password)
	ret := m.ctrl.Call(m, "UserGet", ctx, username, password)
	ret0, _ := ret[0].(user.User)
	ret1, _ := ret[1].(error)
	return ret0, ret1
}

// UserGet indicates an expected call of UserGet
func (mr *MockdberMockRecorder) UserGet(username, password interface{}) *gomock.Call {
func (mr *MockdberMockRecorder) UserGet(ctx, username, password interface{}) *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UserGet", reflect.TypeOf((*Mockdber)(nil).UserGet), username, password)
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UserGet", reflect.TypeOf((*Mockdber)(nil).UserGet), ctx, username, password)
}

// UserGetFromToken mocks base method
func (m *Mockdber) UserGetFromToken(token string) (user.User, error) {
func (m *Mockdber) UserGetFromToken(ctx context.Context, token string) (user.User, error) {
	m.ctrl.T.Helper()
	ret := m.ctrl.Call(m, "UserGetFromToken", token)
	ret := m.ctrl.Call(m, "UserGetFromToken", ctx, token)
	ret0, _ := ret[0].(user.User)
	ret1, _ := ret[1].(error)
	return ret0, ret1
}

// UserGetFromToken indicates an expected call of UserGetFromToken
func (mr *MockdberMockRecorder) UserGetFromToken(token interface{}) *gomock.Call {
func (mr *MockdberMockRecorder) UserGetFromToken(ctx, token interface{}) *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UserGetFromToken", reflect.TypeOf((*Mockdber)(nil).UserGetFromToken), token)
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UserGetFromToken", reflect.TypeOf((*Mockdber)(nil).UserGetFromToken), ctx, token)
}

M internal/c/doc/doc_test.go => internal/c/doc/doc_test.go +8 -6
@@ 13,13 13,15 @@ import (
	gomock "github.com/golang/mock/gomock"
)

var ctx = gomock.Any()

func TestWithoutUser(t *testing.T) {
	t.Parallel()

	var (
		ctrl = gomock.NewController(t)
		db   = doc.NewMockdber(ctrl)
		s    = doc.New(c.New(nil, db, true, "test"), nil, db)
		s    = doc.New(c.New(nil, db, true, "test"), nil)
		ts   = httptest.NewServer(s)
	)



@@ 34,11 36,11 @@ func TestWithUser(t *testing.T) {
	var (
		ctrl = gomock.NewController(t)
		db   = doc.NewMockdber(ctrl)
		s    = doc.New(c.New(nil, db, true, "test"), nil, db)
		s    = doc.New(c.New(nil, db, true, "test"), nil)
		ts   = httptest.NewServer(s)
	)

	db.EXPECT().UserGet("user", "pass").Return(userT.NewMock("", ""), nil).AnyTimes()
	db.EXPECT().UserGet(ctx, "user", "pass").Return(userT.NewMock("", ""), nil).AnyTimes()

	req, _ := http.NewRequest("GET", ts.URL+"/page/doc", nil)
	req.SetBasicAuth("user", "pass")


@@ 52,14 54,14 @@ func TestWithInvalidUserToken(t *testing.T) {
	var (
		ctrl = gomock.NewController(t)
		db   = doc.NewMockdber(ctrl)
		s    = doc.New(c.New(nil, db, true, "test"), nil, db)
		s    = doc.New(c.New(nil, db, true, "test"), nil)
		ts   = httptest.NewServer(s)
		u    = userT.NewMock("", "")
		tok  = u.Token()
		err  = errors.New("placeholder")
	)

	db.EXPECT().UserGetFromToken(tok).Return(nil, err).AnyTimes()
	db.EXPECT().UserGetFromToken(ctx, tok).Return(nil, err).AnyTimes()

	// Shouldn't error.
	req, _ := http.NewRequest("GET", ts.URL+"/page/doc", nil)


@@ 77,7 79,7 @@ func TestNotFound(t *testing.T) {
	var (
		ctrl = gomock.NewController(t)
		db   = doc.NewMockdber(ctrl)
		s    = doc.New(c.New(nil, db, true, "test"), nil, db)
		s    = doc.New(c.New(nil, db, true, "test"), nil)
		ts   = httptest.NewServer(s)
	)


R internal/c/file/mock.go => internal/c/file/file_mock.go +23 -23
@@ 11,72 11,72 @@ import (
	reflect "reflect"
)

// MockDBer is a mock of DBer interface
type MockDBer struct {
// Mockdber is a mock of dber interface
type Mockdber struct {
	ctrl     *gomock.Controller
	recorder *MockDBerMockRecorder
	recorder *MockdberMockRecorder
}

// MockDBerMockRecorder is the mock recorder for MockDBer
type MockDBerMockRecorder struct {
	mock *MockDBer
// MockdberMockRecorder is the mock recorder for Mockdber
type MockdberMockRecorder struct {
	mock *Mockdber
}

// NewMockDBer creates a new mock instance
func NewMockDBer(ctrl *gomock.Controller) *MockDBer {
	mock := &MockDBer{ctrl: ctrl}
	mock.recorder = &MockDBerMockRecorder{mock}
// NewMockdber creates a new mock instance
func NewMockdber(ctrl *gomock.Controller) *Mockdber {
	mock := &Mockdber{ctrl: ctrl}
	mock.recorder = &MockdberMockRecorder{mock}
	return mock
}

// EXPECT returns an object that allows the caller to indicate expected use
func (m *MockDBer) EXPECT() *MockDBerMockRecorder {
func (m *Mockdber) EXPECT() *MockdberMockRecorder {
	return m.recorder
}

// UserGet mocks base method
func (m *MockDBer) UserGet(username, password string) (user.User, error) {
func (m *Mockdber) UserGet(ctx context.Context, username, password string) (user.User, error) {
	m.ctrl.T.Helper()
	ret := m.ctrl.Call(m, "UserGet", username, password)
	ret := m.ctrl.Call(m, "UserGet", ctx, username, password)
	ret0, _ := ret[0].(user.User)
	ret1, _ := ret[1].(error)
	return ret0, ret1
}

// UserGet indicates an expected call of UserGet
func (mr *MockDBerMockRecorder) UserGet(username, password interface{}) *gomock.Call {
func (mr *MockdberMockRecorder) UserGet(ctx, username, password interface{}) *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UserGet", reflect.TypeOf((*MockDBer)(nil).UserGet), username, password)
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UserGet", reflect.TypeOf((*Mockdber)(nil).UserGet), ctx, username, password)
}

// UserGetFromToken mocks base method
func (m *MockDBer) UserGetFromToken(token string) (user.User, error) {
func (m *Mockdber) UserGetFromToken(ctx context.Context, token string) (user.User, error) {
	m.ctrl.T.Helper()
	ret := m.ctrl.Call(m, "UserGetFromToken", token)
	ret := m.ctrl.Call(m, "UserGetFromToken", ctx, token)
	ret0, _ := ret[0].(user.User)
	ret1, _ := ret[1].(error)
	return ret0, ret1
}

// UserGetFromToken indicates an expected call of UserGetFromToken
func (mr *MockDBerMockRecorder) UserGetFromToken(token interface{}) *gomock.Call {
func (mr *MockdberMockRecorder) UserGetFromToken(ctx, token interface{}) *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UserGetFromToken", reflect.TypeOf((*MockDBer)(nil).UserGetFromToken), token)
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UserGetFromToken", reflect.TypeOf((*Mockdber)(nil).UserGetFromToken), ctx, token)
}

// FileExists mocks base method
func (m *MockDBer) FileExists(URL string) (bool, error) {
func (m *Mockdber) FileExists(ctx context.Context, URL string) (bool, error) {
	m.ctrl.T.Helper()
	ret := m.ctrl.Call(m, "FileExists", URL)
	ret := m.ctrl.Call(m, "FileExists", ctx, URL)
	ret0, _ := ret[0].(bool)
	ret1, _ := ret[1].(error)
	return ret0, ret1
}

// FileExists indicates an expected call of FileExists
func (mr *MockDBerMockRecorder) FileExists(URL interface{}) *gomock.Call {
func (mr *MockdberMockRecorder) FileExists(ctx, URL interface{}) *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FileExists", reflect.TypeOf((*MockDBer)(nil).FileExists), URL)
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FileExists", reflect.TypeOf((*Mockdber)(nil).FileExists), ctx, URL)
}

// MockE3er is a mock of E3er interface

M internal/c/file/file_test.go => internal/c/file/file_test.go +8 -6
@@ 14,12 14,14 @@ import (
	gomock "github.com/golang/mock/gomock"
)

var ctx = gomock.Any()

func TestProxyGood(t *testing.T) {
	t.Parallel()

	var (
		ctrl  = gomock.NewController(t)
		db    = file.NewMockDBer(ctrl)
		db    = file.NewMockdber(ctrl)
		e3    = file.NewMockE3er(ctrl)
		s     = file.New(c.New(nil, db, true, "test"), nil, db, e3, E3.DefaultURL)
		ts    = httptest.NewServer(s)


@@ 28,7 30,7 @@ func TestProxyGood(t *testing.T) {
		bytes []byte
	)

	db.EXPECT().FileExists(E3.DefaultURL+fp).Return(true, nil).AnyTimes()
	db.EXPECT().FileExists(ctx, E3.DefaultURL+fp).Return(true, nil).AnyTimes()
	e3.EXPECT().URL().Return(E3.DefaultURL).AnyTimes()
	e3.EXPECT().Proxy(gomock.Any(), url).Return(bytes, nil).AnyTimes()



@@ 42,7 44,7 @@ func TestProxyBad(t *testing.T) {

	var (
		ctrl = gomock.NewController(t)
		db   = file.NewMockDBer(ctrl)
		db   = file.NewMockdber(ctrl)
		e3   = file.NewMockE3er(ctrl)
		s    = file.New(c.New(nil, db, true, "test"), nil, db, e3, E3.DefaultURL)
		ts   = httptest.NewServer(s)


@@ 51,7 53,7 @@ func TestProxyBad(t *testing.T) {
		err  = errors.New("placeholder")
	)

	db.EXPECT().FileExists(E3.DefaultURL+fp).Return(true, nil).AnyTimes()
	db.EXPECT().FileExists(ctx, E3.DefaultURL+fp).Return(true, nil).AnyTimes()
	e3.EXPECT().URL().Return(E3.DefaultURL).AnyTimes()
	e3.EXPECT().Proxy(gomock.Any(), url).Return(nil, err).AnyTimes()



@@ 65,7 67,7 @@ func TestFileDoesNotExit(t *testing.T) {

	var (
		ctrl = gomock.NewController(t)
		db   = file.NewMockDBer(ctrl)
		db   = file.NewMockdber(ctrl)
		e3   = file.NewMockE3er(ctrl)
		s    = file.New(c.New(nil, db, true, "test"), nil, db, e3, E3.DefaultURL)
		ts   = httptest.NewServer(s)


@@ 73,7 75,7 @@ func TestFileDoesNotExit(t *testing.T) {
		err  = errors.New("placeholder")
	)

	db.EXPECT().FileExists(E3.DefaultURL+fp).Return(false, err).AnyTimes()
	db.EXPECT().FileExists(ctx, E3.DefaultURL+fp).Return(false, err).AnyTimes()

	res, err := http.Get(ts.URL + fp)
	assert.Equal(t, nil, err)

M internal/c/hook/hook_mock.go => internal/c/hook/hook_mock.go +25 -24
@@ 5,6 5,7 @@
package hook

import (
	context "context"
	hook "git.sr.ht/~evanj/cms/internal/m/hook"
	space "git.sr.ht/~evanj/cms/internal/m/space"
	user "git.sr.ht/~evanj/cms/internal/m/user"


@@ 36,90 37,90 @@ func (m *Mockdber) EXPECT() *MockdberMockRecorder {
}

// UserGet mocks base method
func (m *Mockdber) UserGet(username, password string) (user.User, error) {
func (m *Mockdber) UserGet(ctx context.Context, username, password string) (user.User, error) {
	m.ctrl.T.Helper()
	ret := m.ctrl.Call(m, "UserGet", username, password)
	ret := m.ctrl.Call(m, "UserGet", ctx, username, password)
	ret0, _ := ret[0].(user.User)
	ret1, _ := ret[1].(error)
	return ret0, ret1
}

// UserGet indicates an expected call of UserGet
func (mr *MockdberMockRecorder) UserGet(username, password interface{}) *gomock.Call {
func (mr *MockdberMockRecorder) UserGet(ctx, username, password interface{}) *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UserGet", reflect.TypeOf((*Mockdber)(nil).UserGet), username, password)
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UserGet", reflect.TypeOf((*Mockdber)(nil).UserGet), ctx, username, password)
}

// UserGetFromToken mocks base method
func (m *Mockdber) UserGetFromToken(token string) (user.User, error) {
func (m *Mockdber) UserGetFromToken(ctx context.Context, token string) (user.User, error) {
	m.ctrl.T.Helper()
	ret := m.ctrl.Call(m, "UserGetFromToken", token)
	ret := m.ctrl.Call(m, "UserGetFromToken", ctx, token)
	ret0, _ := ret[0].(user.User)
	ret1, _ := ret[1].(error)
	return ret0, ret1
}

// UserGetFromToken indicates an expected call of UserGetFromToken
func (mr *MockdberMockRecorder) UserGetFromToken(token interface{}) *gomock.Call {
func (mr *MockdberMockRecorder) UserGetFromToken(ctx, token interface{}) *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UserGetFromToken", reflect.TypeOf((*Mockdber)(nil).UserGetFromToken), token)
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UserGetFromToken", reflect.TypeOf((*Mockdber)(nil).UserGetFromToken), ctx, token)
}

// SpaceGet mocks base method
func (m *Mockdber) SpaceGet(user user.User, spaceID string) (space.Space, error) {
func (m *Mockdber) SpaceGet(ctx context.Context, user user.User, spaceID string) (space.Space, error) {
	m.ctrl.T.Helper()
	ret := m.ctrl.Call(m, "SpaceGet", user, spaceID)
	ret := m.ctrl.Call(m, "SpaceGet", ctx, user, spaceID)
	ret0, _ := ret[0].(space.Space)
	ret1, _ := ret[1].(error)
	return ret0, ret1
}

// SpaceGet indicates an expected call of SpaceGet
func (mr *MockdberMockRecorder) SpaceGet(user, spaceID interface{}) *gomock.Call {
func (mr *MockdberMockRecorder) SpaceGet(ctx, user, spaceID interface{}) *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SpaceGet", reflect.TypeOf((*Mockdber)(nil).SpaceGet), user, spaceID)
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SpaceGet", reflect.TypeOf((*Mockdber)(nil).SpaceGet), ctx, user, spaceID)
}

// HookNew mocks base method
func (m *Mockdber) HookNew(user user.User, space space.Space, url string) (hook.Hook, error) {
func (m *Mockdber) HookNew(ctx context.Context, user user.User, space space.Space, url string) (hook.Hook, error) {
	m.ctrl.T.Helper()
	ret := m.ctrl.Call(m, "HookNew", user, space, url)
	ret := m.ctrl.Call(m, "HookNew", ctx, user, space, url)
	ret0, _ := ret[0].(hook.Hook)
	ret1, _ := ret[1].(error)
	return ret0, ret1
}

// HookNew indicates an expected call of HookNew
func (mr *MockdberMockRecorder) HookNew(user, space, url interface{}) *gomock.Call {
func (mr *MockdberMockRecorder) HookNew(ctx, user, space, url interface{}) *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "HookNew", reflect.TypeOf((*Mockdber)(nil).HookNew), user, space, url)
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "HookNew", reflect.TypeOf((*Mockdber)(nil).HookNew), ctx, user, space, url)
}

// HookGet mocks base method
func (m *Mockdber) HookGet(user user.User, space space.Space, id string) (hook.Hook, error) {
func (m *Mockdber) HookGet(ctx context.Context, user user.User, space space.Space, id string) (hook.Hook, error) {
	m.ctrl.T.Helper()
	ret := m.ctrl.Call(m, "HookGet", user, space, id)
	ret := m.ctrl.Call(m, "HookGet", ctx, user, space, id)
	ret0, _ := ret[0].(hook.Hook)
	ret1, _ := ret[1].(error)
	return ret0, ret1
}

// HookGet indicates an expected call of HookGet
func (mr *MockdberMockRecorder) HookGet(user, space, id interface{}) *gomock.Call {
func (mr *MockdberMockRecorder) HookGet(ctx, user, space, id interface{}) *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "HookGet", reflect.TypeOf((*Mockdber)(nil).HookGet), user, space, id)
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "HookGet", reflect.TypeOf((*Mockdber)(nil).HookGet), ctx, user, space, id)
}

// HookDelete mocks base method
func (m *Mockdber) HookDelete(user user.User, space space.Space, hook hook.Hook) error {
func (m *Mockdber) HookDelete(ctx context.Context, user user.User, space space.Space, hook hook.Hook) error {
	m.ctrl.T.Helper()
	ret := m.ctrl.Call(m, "HookDelete", user, space, hook)
	ret := m.ctrl.Call(m, "HookDelete", ctx, user, space, hook)
	ret0, _ := ret[0].(error)
	return ret0
}

// HookDelete indicates an expected call of HookDelete
func (mr *MockdberMockRecorder) HookDelete(user, space, hook interface{}) *gomock.Call {
func (mr *MockdberMockRecorder) HookDelete(ctx, user, space, hook interface{}) *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "HookDelete", reflect.TypeOf((*Mockdber)(nil).HookDelete), user, space, hook)
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "HookDelete", reflect.TypeOf((*Mockdber)(nil).HookDelete), ctx, user, space, hook)
}

M internal/c/hook/hook_test.go => internal/c/hook/hook_test.go +50 -46
@@ 19,11 19,15 @@ import (
	"github.com/google/uuid"
)

var client = &http.Client{
	CheckRedirect: func(req *http.Request, via []*http.Request) error {
		return http.ErrUseLastResponse
	},
}
var (
	client = &http.Client{
		CheckRedirect: func(req *http.Request, via []*http.Request) error {
			return http.ErrUseLastResponse
		},
	}

	ctx = gomock.Any()
)

func TestNoUser(t *testing.T) {
	t.Parallel()


@@ 74,9 78,9 @@ func TestHookHappyPath(t *testing.T) {
				"method": {"POST"}, // By default net/http doesn't parse body on DELETE.
			},
			func(db *hook.Mockdber) {
				db.EXPECT().UserGet(uItem.Name(), uItem.Pass()).Return(uItem, nil).AnyTimes()
				db.EXPECT().SpaceGet(uItem, sItem.ID()).Return(sItem, nil).AnyTimes()
				db.EXPECT().HookNew(uItem, sItem, hItem.URL()).Return(hItem, nil).AnyTimes()
				db.EXPECT().UserGet(ctx, uItem.Name(), uItem.Pass()).Return(uItem, nil).AnyTimes()
				db.EXPECT().SpaceGet(ctx, uItem, sItem.ID()).Return(sItem, nil).AnyTimes()
				db.EXPECT().HookNew(ctx, uItem, sItem, hItem.URL()).Return(hItem, nil).AnyTimes()
			},
		},
		{


@@ 87,9 91,9 @@ func TestHookHappyPath(t *testing.T) {
				"method": {"GET"}, // By default net/http doesn't parse body on DELETE.
			},
			func(db *hook.Mockdber) {
				db.EXPECT().UserGet(uItem.Name(), uItem.Pass()).Return(uItem, nil).AnyTimes()
				db.EXPECT().SpaceGet(uItem, sItem.ID()).Return(sItem, nil).AnyTimes()
				db.EXPECT().HookGet(uItem, sItem, hItem.ID()).Return(hItem, nil).AnyTimes()
				db.EXPECT().UserGet(ctx, uItem.Name(), uItem.Pass()).Return(uItem, nil).AnyTimes()
				db.EXPECT().SpaceGet(ctx, uItem, sItem.ID()).Return(sItem, nil).AnyTimes()
				db.EXPECT().HookGet(ctx, uItem, sItem, hItem.ID()).Return(hItem, nil).AnyTimes()
			},
		},
		{


@@ 100,10 104,10 @@ func TestHookHappyPath(t *testing.T) {
				"method": {"DELETE"}, // By default net/http doesn't parse body on DELETE.
			},
			func(db *hook.Mockdber) {
				db.EXPECT().UserGet(uItem.Name(), uItem.Pass()).Return(uItem, nil).AnyTimes()
				db.EXPECT().SpaceGet(uItem, sItem.ID()).Return(sItem, nil).AnyTimes()
				db.EXPECT().HookGet(uItem, sItem, hItem.ID()).Return(hItem, nil).AnyTimes()
				db.EXPECT().HookDelete(uItem, sItem, hItem).Return(nil).AnyTimes()
				db.EXPECT().UserGet(ctx, uItem.Name(), uItem.Pass()).Return(uItem, nil).AnyTimes()
				db.EXPECT().SpaceGet(ctx, uItem, sItem.ID()).Return(sItem, nil).AnyTimes()
				db.EXPECT().HookGet(ctx, uItem, sItem, hItem.ID()).Return(hItem, nil).AnyTimes()
				db.EXPECT().HookDelete(ctx, uItem, sItem, hItem).Return(nil).AnyTimes()
			},
		},
	}


@@ 159,9 163,9 @@ func TestHookBadPaths(t *testing.T) {
				"method": {"POST"}, // By default net/http doesn't parse body on DELETE.
			},
			func(db *hook.Mockdber) {
				db.EXPECT().UserGet(uItem.Name(), uItem.Pass()).Return(uItem, nil).AnyTimes()
				db.EXPECT().SpaceGet(uItem, sItem.ID()).Return(nil, err).AnyTimes()
				// db.EXPECT().HookNew(uItem, sItem, hItem.URL()).Return(hItem, nil).AnyTimes()
				db.EXPECT().UserGet(ctx, uItem.Name(), uItem.Pass()).Return(uItem, nil).AnyTimes()
				db.EXPECT().SpaceGet(ctx, uItem, sItem.ID()).Return(nil, err).AnyTimes()
				// db.EXPECT().HookNew(ctx, uItem, sItem, hItem.URL()).Return(hItem, nil).AnyTimes()
			},
		},
		{


@@ 173,9 177,9 @@ func TestHookBadPaths(t *testing.T) {
				"method": {"POST"}, // By default net/http doesn't parse body on DELETE.
			},
			func(db *hook.Mockdber) {
				db.EXPECT().UserGet(uItem.Name(), uItem.Pass()).Return(uItem, nil).AnyTimes()
				db.EXPECT().SpaceGet(uItem, sItem.ID()).Return(sItem, nil).AnyTimes()
				db.EXPECT().HookNew(uItem, sItem, hItem.URL()).Return(nil, err).AnyTimes()
				db.EXPECT().UserGet(ctx, uItem.Name(), uItem.Pass()).Return(uItem, nil).AnyTimes()
				db.EXPECT().SpaceGet(ctx, uItem, sItem.ID()).Return(sItem, nil).AnyTimes()
				db.EXPECT().HookNew(ctx, uItem, sItem, hItem.URL()).Return(nil, err).AnyTimes()
			},
		},
		// GET


@@ 188,9 192,9 @@ func TestHookBadPaths(t *testing.T) {
				"method": {"GET"}, // By default net/http doesn't parse body on DELETE.
			},
			func(db *hook.Mockdber) {
				db.EXPECT().UserGet(uItem.Name(), uItem.Pass()).Return(uItem, nil).AnyTimes()
				db.EXPECT().SpaceGet(uItem, sItem.ID()).Return(nil, err).AnyTimes()
				// db.EXPECT().HookGet(uItem, sItem, hItem.ID()).Return(hItem, nil).AnyTimes()
				db.EXPECT().UserGet(ctx, uItem.Name(), uItem.Pass()).Return(uItem, nil).AnyTimes()
				db.EXPECT().SpaceGet(ctx, uItem, sItem.ID()).Return(nil, err).AnyTimes()
				// db.EXPECT().HookGet(ctx, uItem, sItem, hItem.ID()).Return(hItem, nil).AnyTimes()
			},
		},
		{


@@ 202,9 206,9 @@ func TestHookBadPaths(t *testing.T) {
				"method": {"GET"}, // By default net/http doesn't parse body on DELETE.
			},
			func(db *hook.Mockdber) {
				db.EXPECT().UserGet(uItem.Name(), uItem.Pass()).Return(uItem, nil).AnyTimes()
				db.EXPECT().SpaceGet(uItem, sItem.ID()).Return(sItem, nil).AnyTimes()
				db.EXPECT().HookGet(uItem, sItem, hItem.ID()).Return(nil, err).AnyTimes()
				db.EXPECT().UserGet(ctx, uItem.Name(), uItem.Pass()).Return(uItem, nil).AnyTimes()
				db.EXPECT().SpaceGet(ctx, uItem, sItem.ID()).Return(sItem, nil).AnyTimes()
				db.EXPECT().HookGet(ctx, uItem, sItem, hItem.ID()).Return(nil, err).AnyTimes()
			},
		},
		// DELETE


@@ 217,10 221,10 @@ func TestHookBadPaths(t *testing.T) {
				"method": {"DELETE"}, // By default net/http doesn't parse body on DELETE.
			},
			func(db *hook.Mockdber) {
				db.EXPECT().UserGet(uItem.Name(), uItem.Pass()).Return(uItem, nil).AnyTimes()
				db.EXPECT().SpaceGet(uItem, sItem.ID()).Return(nil, err).AnyTimes()
				// db.EXPECT().HookGet(uItem, sItem, hItem.ID()).Return(hItem, nil).AnyTimes()
				// db.EXPECT().HookDelete(uItem, sItem, hItem).Return(nil).AnyTimes()
				db.EXPECT().UserGet(ctx, uItem.Name(), uItem.Pass()).Return(uItem, nil).AnyTimes()
				db.EXPECT().SpaceGet(ctx, uItem, sItem.ID()).Return(nil, err).AnyTimes()
				// db.EXPECT().HookGet(ctx, uItem, sItem, hItem.ID()).Return(hItem, nil).AnyTimes()
				// db.EXPECT().HookDelete(ctx, uItem, sItem, hItem).Return(nil).AnyTimes()
			},
		},
		{


@@ 232,10 236,10 @@ func TestHookBadPaths(t *testing.T) {
				"method": {"DELETE"}, // By default net/http doesn't parse body on DELETE.
			},
			func(db *hook.Mockdber) {
				db.EXPECT().UserGet(uItem.Name(), uItem.Pass()).Return(uItem, nil).AnyTimes()
				db.EXPECT().SpaceGet(uItem, sItem.ID()).Return(sItem, nil).AnyTimes()
				db.EXPECT().HookGet(uItem, sItem, hItem.ID()).Return(nil, err).AnyTimes()
				// db.EXPECT().HookDelete(uItem, sItem, hItem).Return(nil).AnyTimes()
				db.EXPECT().UserGet(ctx, uItem.Name(), uItem.Pass()).Return(uItem, nil).AnyTimes()
				db.EXPECT().SpaceGet(ctx, uItem, sItem.ID()).Return(sItem, nil).AnyTimes()
				db.EXPECT().HookGet(ctx, uItem, sItem, hItem.ID()).Return(nil, err).AnyTimes()
				// db.EXPECT().HookDelete(ctx, uItem, sItem, hItem).Return(nil).AnyTimes()
			},
		},
		{


@@ 247,10 251,10 @@ func TestHookBadPaths(t *testing.T) {
				"method": {"DELETE"}, // By default net/http doesn't parse body on DELETE.
			},
			func(db *hook.Mockdber) {
				db.EXPECT().UserGet(uItem.Name(), uItem.Pass()).Return(uItem, nil).AnyTimes()
				db.EXPECT().SpaceGet(uItem, sItem.ID()).Return(sItem, nil).AnyTimes()
				db.EXPECT().HookGet(uItem, sItem, hItem.ID()).Return(hItem, nil).AnyTimes()
				db.EXPECT().HookDelete(uItem, sItem, hItem).Return(err).AnyTimes()
				db.EXPECT().UserGet(ctx, uItem.Name(), uItem.Pass()).Return(uItem, nil).AnyTimes()
				db.EXPECT().SpaceGet(ctx, uItem, sItem.ID()).Return(sItem, nil).AnyTimes()
				db.EXPECT().HookGet(ctx, uItem, sItem, hItem.ID()).Return(hItem, nil).AnyTimes()
				db.EXPECT().HookDelete(ctx, uItem, sItem, hItem).Return(err).AnyTimes()
			},
		},
		// PATCH / NOT FOUND


@@ 263,10 267,10 @@ func TestHookBadPaths(t *testing.T) {
				"method": {"PATCH"}, // By default net/http doesn't parse body on DELETE.
			},
			func(db *hook.Mockdber) {
				db.EXPECT().UserGet(uItem.Name(), uItem.Pass()).Return(uItem, nil).AnyTimes()
				db.EXPECT().SpaceGet(uItem, sItem.ID()).Return(sItem, nil).AnyTimes()
				db.EXPECT().HookGet(uItem, sItem, hItem.ID()).Return(hItem, nil).AnyTimes()
				db.EXPECT().HookDelete(uItem, sItem, hItem).Return(err).AnyTimes()
				db.EXPECT().UserGet(ctx, uItem.Name(), uItem.Pass()).Return(uItem, nil).AnyTimes()
				db.EXPECT().SpaceGet(ctx, uItem, sItem.ID()).Return(sItem, nil).AnyTimes()
				db.EXPECT().HookGet(ctx, uItem, sItem, hItem.ID()).Return(hItem, nil).AnyTimes()
				db.EXPECT().HookDelete(ctx, uItem, sItem, hItem).Return(err).AnyTimes()
			},
		},
	}


@@ 312,9 316,9 @@ func TestHookWeirdPath(t *testing.T) {
		{
			http.StatusOK,
			func(db *hook.Mockdber) {
				db.EXPECT().UserGet(uItem.Name(), uItem.Pass()).Return(uItem, nil).AnyTimes()
				db.EXPECT().SpaceGet(uItem, sItem.ID()).Return(sItem, nil).AnyTimes()
				db.EXPECT().HookGet(uItem, sItem, hItem.ID()).Return(hItem, nil).AnyTimes()
				db.EXPECT().UserGet(ctx, uItem.Name(), uItem.Pass()).Return(uItem, nil).AnyTimes()
				db.EXPECT().SpaceGet(ctx, uItem, sItem.ID()).Return(sItem, nil).AnyTimes()
				db.EXPECT().HookGet(ctx, uItem, sItem, hItem.ID()).Return(hItem, nil).AnyTimes()
			},
		},
	}

R internal/c/redirect/mock.go => internal/c/redirect/redirect_mock.go +9 -8
@@ 5,6 5,7 @@
package redirect

import (
	context "context"
	user "git.sr.ht/~evanj/cms/internal/m/user"
	gomock "github.com/golang/mock/gomock"
	reflect "reflect"


@@ 34,31 35,31 @@ func (m *Mockdber) EXPECT() *MockdberMockRecorder {
}

// UserGet mocks base method
func (m *Mockdber) UserGet(username, password string) (user.User, error) {
func (m *Mockdber) UserGet(ctx context.Context, username, password string) (user.User, error) {
	m.ctrl.T.Helper()
	ret := m.ctrl.Call(m, "UserGet", username, password)
	ret := m.ctrl.Call(m, "UserGet", ctx, username, password)
	ret0, _ := ret[0].(user.User)
	ret1, _ := ret[1].(error)
	return ret0, ret1
}

// UserGet indicates an expected call of UserGet
func (mr *MockdberMockRecorder) UserGet(username, password interface{}) *gomock.Call {
func (mr *MockdberMockRecorder) UserGet(ctx, username, password interface{}) *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UserGet", reflect.TypeOf((*Mockdber)(nil).UserGet), username, password)
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UserGet", reflect.TypeOf((*Mockdber)(nil).UserGet), ctx, username, password)
}

// UserGetFromToken mocks base method
func (m *Mockdber) UserGetFromToken(token string) (user.User, error) {
func (m *Mockdber) UserGetFromToken(ctx context.Context, token string) (user.User, error) {
	m.ctrl.T.Helper()
	ret := m.ctrl.Call(m, "UserGetFromToken", token)
	ret := m.ctrl.Call(m, "UserGetFromToken", ctx, token)
	ret0, _ := ret[0].(user.User)
	ret1, _ := ret[1].(error)
	return ret0, ret1
}

// UserGetFromToken indicates an expected call of UserGetFromToken
func (mr *MockdberMockRecorder) UserGetFromToken(token interface{}) *gomock.Call {
func (mr *MockdberMockRecorder) UserGetFromToken(ctx, token interface{}) *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UserGetFromToken", reflect.TypeOf((*Mockdber)(nil).UserGetFromToken), token)
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UserGetFromToken", reflect.TypeOf((*Mockdber)(nil).UserGetFromToken), ctx, token)
}

M internal/c/redirect/redirect_test.go => internal/c/redirect/redirect_test.go +2 -0
@@ 12,6 12,8 @@ import (
	gomock "github.com/golang/mock/gomock"
)

var ctx = gomock.Any()

func TestRedirect(t *testing.T) {
	t.Parallel()


M internal/c/space/space.go => internal/c/space/space.go +5 -5
@@ 35,11 35,11 @@ type dber interface {
	UserGetFromToken(ctx context.Context, token string) (user.User, error)
	SpaceNew(ctx context.Context, user user.User, name, desc string) (space.Space, error)
	SpaceGet(ctx context.Context, user user.User, spaceID string) (space.Space, error)
	SpaceUpdate(ctx context.Context, user user.User, space space.Space, name, desc string) (space.Space, error)
	SpaceCopy(ctx context.Context, user user.User, space space.Space, name, desc string) (space.Space, error)
	SpaceDelete(ctx context.Context, user user.User, space space.Space) error
	ContentTypesPerSpace(ctx context.Context, user user.User, space space.Space, before int) (contenttype.ContentTypeList, error)
	HooksPerSpace(ctx context.Context, user user.User, space space.Space, before int) (hook.HookList, error)
	SpaceUpdate(ctx context.Context, user user.User, s space.Space, name, desc string) (space.Space, error)
	SpaceCopy(ctx context.Context, user user.User, s space.Space, name, desc string) (space.Space, error)
	SpaceDelete(ctx context.Context, user user.User, s space.Space) error
	ContentTypesPerSpace(ctx context.Context, user user.User, s space.Space, before int) (contenttype.ContentTypeList, error)
	HooksPerSpace(ctx context.Context, user user.User, s space.Space, before int) (hook.HookList, error)
}

func New(c *c.Controller, log *log.Logger, db dber) *Space {

M internal/c/space/space_mock.go => internal/c/space/space_mock.go +38 -38
@@ 5,13 5,13 @@
package space

import (
	reflect "reflect"

	context "context"
	contenttype "git.sr.ht/~evanj/cms/internal/m/contenttype"
	hook "git.sr.ht/~evanj/cms/internal/m/hook"
	space "git.sr.ht/~evanj/cms/internal/m/space"
	user "git.sr.ht/~evanj/cms/internal/m/user"
	gomock "github.com/golang/mock/gomock"
	reflect "reflect"
)

// Mockdber is a mock of dber interface


@@ 38,135 38,135 @@ func (m *Mockdber) EXPECT() *MockdberMockRecorder {
}

// UserGet mocks base method
func (m *Mockdber) UserGet(username, password string) (user.User, error) {
func (m *Mockdber) UserGet(ctx context.Context, username, password string) (user.User, error) {
	m.ctrl.T.Helper()
	ret := m.ctrl.Call(m, "UserGet", username, password)
	ret := m.ctrl.Call(m, "UserGet", ctx, username, password)
	ret0, _ := ret[0].(user.User)
	ret1, _ := ret[1].(error)
	return ret0, ret1
}

// UserGet indicates an expected call of UserGet
func (mr *MockdberMockRecorder) UserGet(username, password interface{}) *gomock.Call {
func (mr *MockdberMockRecorder) UserGet(ctx, username, password interface{}) *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UserGet", reflect.TypeOf((*Mockdber)(nil).UserGet), username, password)
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UserGet", reflect.TypeOf((*Mockdber)(nil).UserGet), ctx, username, password)
}

// UserGetFromToken mocks base method
func (m *Mockdber) UserGetFromToken(token string) (user.User, error) {
func (m *Mockdber) UserGetFromToken(ctx context.Context, token string) (user.User, error) {
	m.ctrl.T.Helper()
	ret := m.ctrl.Call(m, "UserGetFromToken", token)
	ret := m.ctrl.Call(m, "UserGetFromToken", ctx, token)
	ret0, _ := ret[0].(user.User)
	ret1, _ := ret[1].(error)
	return ret0, ret1
}

// UserGetFromToken indicates an expected call of UserGetFromToken
func (mr *MockdberMockRecorder) UserGetFromToken(token interface{}) *gomock.Call {
func (mr *MockdberMockRecorder) UserGetFromToken(ctx, token interface{}) *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UserGetFromToken", reflect.TypeOf((*Mockdber)(nil).UserGetFromToken), token)
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UserGetFromToken", reflect.TypeOf((*Mockdber)(nil).UserGetFromToken), ctx, token)
}

// SpaceNew mocks base method
func (m *Mockdber) SpaceNew(user user.User, name, desc string) (space.Space, error) {
func (m *Mockdber) SpaceNew(ctx context.Context, user user.User, name, desc string) (space.Space, error) {
	m.ctrl.T.Helper()
	ret := m.ctrl.Call(m, "SpaceNew", user, name, desc)
	ret := m.ctrl.Call(m, "SpaceNew", ctx, user, name, desc)
	ret0, _ := ret[0].(space.Space)
	ret1, _ := ret[1].(error)
	return ret0, ret1
}

// SpaceNew indicates an expected call of SpaceNew
func (mr *MockdberMockRecorder) SpaceNew(user, name, desc interface{}) *gomock.Call {
func (mr *MockdberMockRecorder) SpaceNew(ctx, user, name, desc interface{}) *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SpaceNew", reflect.TypeOf((*Mockdber)(nil).SpaceNew), user, name, desc)
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SpaceNew", reflect.TypeOf((*Mockdber)(nil).SpaceNew), ctx, user, name, desc)
}

// SpaceGet mocks base method
func (m *Mockdber) SpaceGet(user user.User, spaceID string) (space.Space, error) {
func (m *Mockdber) SpaceGet(ctx context.Context, user user.User, spaceID string) (space.Space, error) {
	m.ctrl.T.Helper()
	ret := m.ctrl.Call(m, "SpaceGet", user, spaceID)
	ret := m.ctrl.Call(m, "SpaceGet", ctx, user, spaceID)
	ret0, _ := ret[0].(space.Space)
	ret1, _ := ret[1].(error)
	return ret0, ret1
}

// SpaceGet indicates an expected call of SpaceGet
func (mr *MockdberMockRecorder) SpaceGet(user, spaceID interface{}) *gomock.Call {
func (mr *MockdberMockRecorder) SpaceGet(ctx, user, spaceID interface{}) *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SpaceGet", reflect.TypeOf((*Mockdber)(nil).SpaceGet), user, spaceID)
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SpaceGet", reflect.TypeOf((*Mockdber)(nil).SpaceGet), ctx, user, spaceID)
}

// SpaceUpdate mocks base method
func (m *Mockdber) SpaceUpdate(user user.User, s space.Space, name, desc string) (space.Space, error) {
func (m *Mockdber) SpaceUpdate(ctx context.Context, user user.User, s space.Space, name, desc string) (space.Space, error) {
	m.ctrl.T.Helper()
	ret := m.ctrl.Call(m, "SpaceUpdate", user, s, name, desc)
	ret := m.ctrl.Call(m, "SpaceUpdate", ctx, user, s, name, desc)
	ret0, _ := ret[0].(space.Space)
	ret1, _ := ret[1].(error)
	return ret0, ret1
}

// SpaceUpdate indicates an expected call of SpaceUpdate
func (mr *MockdberMockRecorder) SpaceUpdate(user, space, name, desc interface{}) *gomock.Call {
func (mr *MockdberMockRecorder) SpaceUpdate(ctx, user, s, name, desc interface{}) *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SpaceUpdate", reflect.TypeOf((*Mockdber)(nil).SpaceUpdate), user, space, name, desc)
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SpaceUpdate", reflect.TypeOf((*Mockdber)(nil).SpaceUpdate), ctx, user, s, name, desc)
}

// SpaceCopy mocks base method
func (m *Mockdber) SpaceCopy(user user.User, s space.Space, name, desc string) (space.Space, error) {
func (m *Mockdber) SpaceCopy(ctx context.Context, user user.User, s space.Space, name, desc string) (space.Space, error) {
	m.ctrl.T.Helper()
	ret := m.ctrl.Call(m, "SpaceCopy", user, s, name, desc)
	ret := m.ctrl.Call(m, "SpaceCopy", ctx, user, s, name, desc)
	ret0, _ := ret[0].(space.Space)
	ret1, _ := ret[1].(error)
	return ret0, ret1
}

// SpaceCopy indicates an expected call of SpaceCopy
func (mr *MockdberMockRecorder) SpaceCopy(user, space, name, desc interface{}) *gomock.Call {
func (mr *MockdberMockRecorder) SpaceCopy(ctx, user, s, name, desc interface{}) *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SpaceCopy", reflect.TypeOf((*Mockdber)(nil).SpaceCopy), user, space, name, desc)
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SpaceCopy", reflect.TypeOf((*Mockdber)(nil).SpaceCopy), ctx, user, s, name, desc)
}

// SpaceDelete mocks base method
func (m *Mockdber) SpaceDelete(user user.User, space space.Space) error {
func (m *Mockdber) SpaceDelete(ctx context.Context, user user.User, s space.Space) error {
	m.ctrl.T.Helper()
	ret := m.ctrl.Call(m, "SpaceDelete", user, space)
	ret := m.ctrl.Call(m, "SpaceDelete", ctx, user, s)
	ret0, _ := ret[0].(error)
	return ret0
}

// SpaceDelete indicates an expected call of SpaceDelete
func (mr *MockdberMockRecorder) SpaceDelete(user, space interface{}) *gomock.Call {
func (mr *MockdberMockRecorder) SpaceDelete(ctx, user, s interface{}) *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SpaceDelete", reflect.TypeOf((*Mockdber)(nil).SpaceDelete), user, space)
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SpaceDelete", reflect.TypeOf((*Mockdber)(nil).SpaceDelete), ctx, user, s)
}

// ContentTypesPerSpace mocks base method
func (m *Mockdber) ContentTypesPerSpace(user user.User, space space.Space, before int) (contenttype.ContentTypeList, error) {
func (m *Mockdber) ContentTypesPerSpace(ctx context.Context, user user.User, s space.Space, before int) (contenttype.ContentTypeList, error) {
	m.ctrl.T.Helper()
	ret := m.ctrl.Call(m, "ContentTypesPerSpace", user, space, before)
	ret := m.ctrl.Call(m, "ContentTypesPerSpace", ctx, user, s, before)
	ret0, _ := ret[0].(contenttype.ContentTypeList)
	ret1, _ := ret[1].(error)
	return ret0, ret1
}

// ContentTypesPerSpace indicates an expected call of ContentTypesPerSpace
func (mr *MockdberMockRecorder) ContentTypesPerSpace(user, space, before interface{}) *gomock.Call {
func (mr *MockdberMockRecorder) ContentTypesPerSpace(ctx, user, s, before interface{}) *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ContentTypesPerSpace", reflect.TypeOf((*Mockdber)(nil).ContentTypesPerSpace), user, space, before)
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ContentTypesPerSpace", reflect.TypeOf((*Mockdber)(nil).ContentTypesPerSpace), ctx, user, s, before)
}

// HooksPerSpace mocks base method
func (m *Mockdber) HooksPerSpace(user user.User, space space.Space, before int) (hook.HookList, error) {
func (m *Mockdber) HooksPerSpace(ctx context.Context, user user.User, s space.Space, before int) (hook.HookList, error) {
	m.ctrl.T.Helper()
	ret := m.ctrl.Call(m, "HooksPerSpace", user, space, before)
	ret := m.ctrl.Call(m, "HooksPerSpace", ctx, user, s, before)
	ret0, _ := ret[0].(hook.HookList)
	ret1, _ := ret[1].(error)
	return ret0, ret1
}

// HooksPerSpace indicates an expected call of HooksPerSpace
func (mr *MockdberMockRecorder) HooksPerSpace(user, space, before interface{}) *gomock.Call {
func (mr *MockdberMockRecorder) HooksPerSpace(ctx, user, s, before interface{}) *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "HooksPerSpace", reflect.TypeOf((*Mockdber)(nil).HooksPerSpace), user, space, before)
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "HooksPerSpace", reflect.TypeOf((*Mockdber)(nil).HooksPerSpace), ctx, user, s, before)
}

M internal/c/space/space_test.go => internal/c/space/space_test.go +39 -35
@@ 22,11 22,15 @@ import (
	"github.com/google/uuid"
)

var client = &http.Client{
	CheckRedirect: func(req *http.Request, via []*http.Request) error {
		return http.ErrUseLastResponse
	},
}
var (
	client = &http.Client{
		CheckRedirect: func(req *http.Request, via []*http.Request) error {
			return http.ErrUseLastResponse
		},
	}

	ctx = gomock.Any()
)

func emptyreq(ts *httptest.Server, method string) (*http.Response, error) {
	req, err := newrequest(method, ts.URL, nil)


@@ 126,84 130,84 @@ func TestAll(t *testing.T) {
		SpaceTest{
			createSC: http.StatusFound,
			create: func(db *space.Mockdber) {
				db.EXPECT().UserGet(uname, upass).Return(uItem, nil).AnyTimes()
				db.EXPECT().SpaceNew(uItem, sname, sdesc).Return(sItem, nil).AnyTimes()
				db.EXPECT().UserGet(ctx, uname, upass).Return(uItem, nil).AnyTimes()
				db.EXPECT().SpaceNew(ctx, uItem, sname, sdesc).Return(sItem, nil).AnyTimes()
			},
			getSC: http.StatusOK,
			get: func(db *space.Mockdber) {
				db.EXPECT().UserGet(uname, upass).Return(uItem, nil).AnyTimes()
				db.EXPECT().SpaceGet(uItem, sItem.ID()).Return(sItem, nil).AnyTimes()
				db.EXPECT().ContentTypesPerSpace(uItem, sItem, 0).Return(contentTypeList, nil).AnyTimes()
				db.EXPECT().HooksPerSpace(uItem, sItem, 0).Return(hookList, nil).AnyTimes()
				db.EXPECT().UserGet(ctx, uname, upass).Return(uItem, nil).AnyTimes()
				db.EXPECT().SpaceGet(ctx, uItem, sItem.ID()).Return(sItem, nil).AnyTimes()
				db.EXPECT().ContentTypesPerSpace(ctx, uItem, sItem, 0).Return(contentTypeList, nil).AnyTimes()
				db.EXPECT().HooksPerSpace(ctx, uItem, sItem, 0).Return(hookList, nil).AnyTimes()
			},
			updateSC: http.StatusFound,
			update: func(db *space.Mockdber) {
				db.EXPECT().UserGet(uname, upass).Return(uItem, nil).AnyTimes()
				db.EXPECT().SpaceGet(uItem, sItem.ID()).Return(sItem, nil).AnyTimes()
				db.EXPECT().SpaceUpdate(uItem, sItem, snameUpdate, sdescUpdate).Return(sItemUpdate, nil).AnyTimes()
				db.EXPECT().UserGet(ctx, uname, upass).Return(uItem, nil).AnyTimes()
				db.EXPECT().SpaceGet(ctx, uItem, sItem.ID()).Return(sItem, nil).AnyTimes()
				db.EXPECT().SpaceUpdate(ctx, uItem, sItem, snameUpdate, sdescUpdate).Return(sItemUpdate, nil).AnyTimes()
			},
			copySC: http.StatusFound,
			copy: func(db *space.Mockdber) {
				db.EXPECT().UserGet(uname, upass).Return(uItem, nil).AnyTimes()
				db.EXPECT().SpaceGet(uItem, sItemUpdate.ID()).Return(sItemUpdate, nil).AnyTimes()
				db.EXPECT().SpaceCopy(uItem, sItemUpdate, snameCopy, sdescCopy).Return(sItemCopy, nil).AnyTimes()
				db.EXPECT().UserGet(ctx, uname, upass).Return(uItem, nil).AnyTimes()
				db.EXPECT().SpaceGet(ctx, uItem, sItemUpdate.ID()).Return(sItemUpdate, nil).AnyTimes()
				db.EXPECT().SpaceCopy(ctx, uItem, sItemUpdate, snameCopy, sdescCopy).Return(sItemCopy, nil).AnyTimes()
			},
			deleteSC: http.StatusFound,
			delete: func(db *space.Mockdber) {
				db.EXPECT().UserGet(uname, upass).Return(uItem, nil).AnyTimes()
				db.EXPECT().SpaceGet(uItem, sItem.ID()).Return(sItem, nil).AnyTimes()
				db.EXPECT().SpaceDelete(uItem, sItem).Return(nil).AnyTimes()
				db.EXPECT().UserGet(ctx, uname, upass).Return(uItem, nil).AnyTimes()
				db.EXPECT().SpaceGet(ctx, uItem, sItem.ID()).Return(sItem, nil).AnyTimes()
				db.EXPECT().SpaceDelete(ctx, uItem, sItem).Return(nil).AnyTimes()
			},
		},

		SpaceTest{
			createSC: http.StatusBadRequest,
			create: func(db *space.Mockdber) {
				db.EXPECT().UserGet(uname, upass).Return(nil, c.ErrNoLogin).AnyTimes()
				db.EXPECT().UserGet(ctx, uname, upass).Return(nil, c.ErrNoLogin).AnyTimes()
			},
			getSC: http.StatusBadRequest,
			get: func(db *space.Mockdber) {
				db.EXPECT().UserGet(uname, upass).Return(uItem, nil).AnyTimes()
				db.EXPECT().UserGet(ctx, uname, upass).Return(uItem, nil).AnyTimes()
			},
			updateSC: http.StatusBadRequest,
			update: func(db *space.Mockdber) {
				db.EXPECT().UserGet(uname, upass).Return(uItem, nil).AnyTimes()
				db.EXPECT().UserGet(ctx, uname, upass).Return(uItem, nil).AnyTimes()
			},
			copySC: http.StatusBadRequest,
			copy: func(db *space.Mockdber) {
				db.EXPECT().UserGet(uname, upass).Return(uItem, nil).AnyTimes()
				db.EXPECT().UserGet(ctx, uname, upass).Return(uItem, nil).AnyTimes()
			},
			deleteSC: http.StatusBadRequest,
			delete: func(db *space.Mockdber) {
				db.EXPECT().UserGet(uname, upass).Return(uItem, nil).AnyTimes()
				db.EXPECT().UserGet(ctx, uname, upass).Return(uItem, nil).AnyTimes()
			},
		},

		SpaceTest{
			createSC: http.StatusBadRequest,
			create: func(db *space.Mockdber) {
				db.EXPECT().UserGet(uname, upass).Return(uItem, nil).AnyTimes()
				db.EXPECT().SpaceNew(uItem, sname, sdesc).Return(nil, space.ErrNoSpace).AnyTimes()
				db.EXPECT().UserGet(ctx, uname, upass).Return(uItem, nil).AnyTimes()
				db.EXPECT().SpaceNew(ctx, uItem, sname, sdesc).Return(nil, space.ErrNoSpace).AnyTimes()
			},
			getSC: http.StatusNotFound,
			get: func(db *space.Mockdber) {
				db.EXPECT().UserGet(uname, upass).Return(uItem, nil).AnyTimes()
				db.EXPECT().SpaceGet(uItem, sItem.ID()).Return(nil, space.ErrNoSpace).AnyTimes()
				db.EXPECT().UserGet(ctx, uname, upass).Return(uItem, nil).AnyTimes()
				db.EXPECT().SpaceGet(ctx, uItem, sItem.ID()).Return(nil, space.ErrNoSpace).AnyTimes()
			},
			updateSC: http.StatusNotFound,
			update: func(db *space.Mockdber) {
				db.EXPECT().UserGet(uname, upass).Return(uItem, nil).AnyTimes()
				db.EXPECT().SpaceGet(uItem, sItem.ID()).Return(nil, space.ErrNoSpace).AnyTimes()
				db.EXPECT().UserGet(ctx, uname, upass).Return(uItem, nil).AnyTimes()
				db.EXPECT().SpaceGet(ctx, uItem, sItem.ID()).Return(nil, space.ErrNoSpace).AnyTimes()
			},
			copySC: http.StatusNotFound,
			copy: func(db *space.Mockdber) {
				db.EXPECT().UserGet(uname, upass).Return(uItem, nil).AnyTimes()
				db.EXPECT().SpaceGet(uItem, sItemUpdate.ID()).Return(nil, space.ErrNoSpace).AnyTimes()
				db.EXPECT().UserGet(ctx, uname, upass).Return(uItem, nil).AnyTimes()
				db.EXPECT().SpaceGet(ctx, uItem, sItemUpdate.ID()).Return(nil, space.ErrNoSpace).AnyTimes()
			},
			deleteSC: http.StatusNotFound,
			delete: func(db *space.Mockdber) {
				db.EXPECT().UserGet(uname, upass).Return(uItem, nil).AnyTimes()
				db.EXPECT().SpaceGet(uItem, sItem.ID()).Return(nil, space.ErrNoSpace).AnyTimes()
				db.EXPECT().UserGet(ctx, uname, upass).Return(uItem, nil).AnyTimes()
				db.EXPECT().SpaceGet(ctx, uItem, sItem.ID()).Return(nil, space.ErrNoSpace).AnyTimes()
			},
		},
	}

A internal/c/stripe/stripe_mock.go => internal/c/stripe/stripe_mock.go +48 -0
@@ 0,0 1,48 @@
// Code generated by MockGen. DO NOT EDIT.
// Source: stripe.go

// Package stripe is a generated GoMock package.
package stripe

import (
	context "context"
	gomock "github.com/golang/mock/gomock"
	reflect "reflect"
)

// MockStriper is a mock of Striper interface
type MockStriper struct {
	ctrl     *gomock.Controller
	recorder *MockStriperMockRecorder
}

// MockStriperMockRecorder is the mock recorder for MockStriper
type MockStriperMockRecorder struct {
	mock *MockStriper
}

// NewMockStriper creates a new mock instance
func NewMockStriper(ctrl *gomock.Controller) *MockStriper {
	mock := &MockStriper{ctrl: ctrl}
	mock.recorder = &MockStriperMockRecorder{mock}
	return mock
}

// EXPECT returns an object that allows the caller to indicate expected use
func (m *MockStriper) EXPECT() *MockStriperMockRecorder {
	return m.recorder
}

// CompleteCheckout mocks base method
func (m *MockStriper) CompleteCheckout(ctx context.Context, sessionID string) error {
	m.ctrl.T.Helper()
	ret := m.ctrl.Call(m, "CompleteCheckout", ctx, sessionID)
	ret0, _ := ret[0].(error)
	return ret0
}

// CompleteCheckout indicates an expected call of CompleteCheckout
func (mr *MockStriperMockRecorder) CompleteCheckout(ctx, sessionID interface{}) *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CompleteCheckout", reflect.TypeOf((*MockStriper)(nil).CompleteCheckout), ctx, sessionID)
}

M internal/c/user/user_mock.go => internal/c/user/user_mock.go +33 -32
@@ 5,6 5,7 @@
package user

import (
	context "context"
	space "git.sr.ht/~evanj/cms/internal/m/space"
	tier "git.sr.ht/~evanj/cms/internal/m/tier"
	user "git.sr.ht/~evanj/cms/internal/m/user"


@@ 36,93 37,93 @@ func (m *Mockdber) EXPECT() *MockdberMockRecorder {
}

// UserNew mocks base method
func (m *Mockdber) UserNew(username, password, verifyPassword string) (user.User, error) {
func (m *Mockdber) UserNew(ctx context.Context, username, password, verifyPassword string) (user.User, error) {
	m.ctrl.T.Helper()
	ret := m.ctrl.Call(m, "UserNew", username, password, verifyPassword)
	ret := m.ctrl.Call(m, "UserNew", ctx, username, password, verifyPassword)
	ret0, _ := ret[0].(user.User)
	ret1, _ := ret[1].(error)
	return ret0, ret1
}

// UserNew indicates an expected call of UserNew
func (mr *MockdberMockRecorder) UserNew(username, password, verifyPassword interface{}) *gomock.Call {
func (mr *MockdberMockRecorder) UserNew(ctx, username, password, verifyPassword interface{}) *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UserNew", reflect.TypeOf((*Mockdber)(nil).UserNew), username, password, verifyPassword)
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UserNew", reflect.TypeOf((*Mockdber)(nil).UserNew), ctx, username, password, verifyPassword)
}

// UserGet mocks base method
func (m *Mockdber) UserGet(username, password string) (user.User, error) {
func (m *Mockdber) UserGet(ctx context.Context, username, password string) (user.User, error) {
	m.ctrl.T.Helper()
	ret := m.ctrl.Call(m, "UserGet", username, password)
	ret := m.ctrl.Call(m, "UserGet", ctx, username, password)
	ret0, _ := ret[0].(user.User)
	ret1, _ := ret[1].(error)
	return ret0, ret1
}

// UserGet indicates an expected call of UserGet
func (mr *MockdberMockRecorder) UserGet(username, password interface{}) *gomock.Call {
func (mr *MockdberMockRecorder) UserGet(ctx, username, password interface{}) *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UserGet", reflect.TypeOf((*Mockdber)(nil).UserGet), username, password)
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UserGet", reflect.TypeOf((*Mockdber)(nil).UserGet), ctx, username, password)
}

// UserGetFromToken mocks base method
func (m *Mockdber) UserGetFromToken(token string) (user.User, error) {
func (m *Mockdber) UserGetFromToken(ctx context.Context, token string) (user.User, error) {
	m.ctrl.T.Helper()
	ret := m.ctrl.Call(m, "UserGetFromToken", token)
	ret := m.ctrl.Call(m, "UserGetFromToken", ctx, token)
	ret0, _ := ret[0].(user.User)
	ret1, _ := ret[1].(error)
	return ret0, ret1
}

// UserGetFromToken indicates an expected call of UserGetFromToken
func (mr *MockdberMockRecorder) UserGetFromToken(token interface{}) *gomock.Call {
func (mr *MockdberMockRecorder) UserGetFromToken(ctx, token interface{}) *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UserGetFromToken", reflect.TypeOf((*Mockdber)(nil).UserGetFromToken), token)
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UserGetFromToken", reflect.TypeOf((*Mockdber)(nil).UserGetFromToken), ctx, token)
}

// UserSetEmail mocks base method
func (m *Mockdber) UserSetEmail(u user.User, email string) (user.User, error) {
func (m *Mockdber) UserSetEmail(ctx context.Context, u user.User, email string) (user.User, error) {
	m.ctrl.T.Helper()
	ret := m.ctrl.Call(m, "UserSetEmail", u, email)
	ret := m.ctrl.Call(m, "UserSetEmail", ctx, u, email)
	ret0, _ := ret[0].(user.User)
	ret1, _ := ret[1].(error)
	return ret0, ret1
}

// UserSetEmail indicates an expected call of UserSetEmail
func (mr *MockdberMockRecorder) UserSetEmail(u, email interface{}) *gomock.Call {
func (mr *MockdberMockRecorder) UserSetEmail(ctx, u, email interface{}) *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UserSetEmail", reflect.TypeOf((*Mockdber)(nil).UserSetEmail), u, email)
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UserSetEmail", reflect.TypeOf((*Mockdber)(nil).UserSetEmail), ctx, u, email)
}

// UserSetPassword mocks base method
func (m *Mockdber) UserSetPassword(u user.User, current, password, verify string) (user.User, error) {
func (m *Mockdber) UserSetPassword(ctx context.Context, u user.User, current, password, verify string) (user.User, error) {
	m.ctrl.T.Helper()
	ret := m.ctrl.Call(m, "UserSetPassword", u, current, password, verify)
	ret := m.ctrl.Call(m, "UserSetPassword", ctx, u, current, password, verify)
	ret0, _ := ret[0].(user.User)
	ret1, _ := ret[1].(error)
	return ret0, ret1
}

// UserSetPassword indicates an expected call of UserSetPassword
func (mr *MockdberMockRecorder) UserSetPassword(u, current, password, verify interface{}) *gomock.Call {
func (mr *MockdberMockRecorder) UserSetPassword(ctx, u, current, password, verify interface{}) *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UserSetPassword", reflect.TypeOf((*Mockdber)(nil).UserSetPassword), u, current, password, verify)
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UserSetPassword", reflect.TypeOf((*Mockdber)(nil).UserSetPassword), ctx, u, current, password, verify)
}

// SpacesPerUser mocks base method
func (m *Mockdber) SpacesPerUser(user user.User, before int) (space.SpaceList, error) {
func (m *Mockdber) SpacesPerUser(ctx context.Context, user user.User, before int) (space.SpaceList, error) {
	m.ctrl.T.Helper()
	ret := m.ctrl.Call(m, "SpacesPerUser", user, before)
	ret := m.ctrl.Call(m, "SpacesPerUser", ctx, user, before)
	ret0, _ := ret[0].(space.SpaceList)
	ret1, _ := ret[1].(error)
	return ret0, ret1
}

// SpacesPerUser indicates an expected call of SpacesPerUser
func (mr *MockdberMockRecorder) SpacesPerUser(user, before interface{}) *gomock.Call {
func (mr *MockdberMockRecorder) SpacesPerUser(ctx, user, before interface{}) *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SpacesPerUser", reflect.TypeOf((*Mockdber)(nil).SpacesPerUser), user, before)
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SpacesPerUser", reflect.TypeOf((*Mockdber)(nil).SpacesPerUser), ctx, user, before)
}

// MockStriper is a mock of Striper interface


@@ 149,9 150,9 @@ func (m *MockStriper) EXPECT() *MockStriperMockRecorder {
}

// StartCheckout mocks base method
func (m *MockStriper) StartCheckout(user user.User, t tier.Tier) (string, string, error) {
func (m *MockStriper) StartCheckout(ctx context.Context, user user.User, t tier.Tier) (string, string, error) {
	m.ctrl.T.Helper()
	ret := m.ctrl.Call(m, "StartCheckout", user, t)
	ret := m.ctrl.Call(m, "StartCheckout", ctx, user, t)
	ret0, _ := ret[0].(string)
	ret1, _ := ret[1].(string)
	ret2, _ := ret[2].(error)


@@ 159,21 160,21 @@ func (m *MockStriper) StartCheckout(user user.User, t tier.Tier) (string, string
}

// StartCheckout indicates an expected call of StartCheckout
func (mr *MockStriperMockRecorder) StartCheckout(user, t interface{}) *gomock.Call {
func (mr *MockStriperMockRecorder) StartCheckout(ctx, user, t interface{}) *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StartCheckout", reflect.TypeOf((*MockStriper)(nil).StartCheckout), user, t)
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StartCheckout", reflect.TypeOf((*MockStriper)(nil).StartCheckout), ctx, user, t)
}

// CancelSubscription mocks base method
func (m *MockStriper) CancelSubscription(user user.User) error {
func (m *MockStriper) CancelSubscription(ctx context.Context, user user.User) error {
	m.ctrl.T.Helper()
	ret := m.ctrl.Call(m, "CancelSubscription", user)
	ret := m.ctrl.Call(m, "CancelSubscription", ctx, user)
	ret0, _ := ret[0].(error)
	return ret0
}

// CancelSubscription indicates an expected call of CancelSubscription
func (mr *MockStriperMockRecorder) CancelSubscription(user interface{}) *gomock.Call {
func (mr *MockStriperMockRecorder) CancelSubscription(ctx, user interface{}) *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CancelSubscription", reflect.TypeOf((*MockStriper)(nil).CancelSubscription), user)
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CancelSubscription", reflect.TypeOf((*MockStriper)(nil).CancelSubscription), ctx, user)
}

M internal/c/user/user_test.go => internal/c/user/user_test.go +14 -12
@@ 17,6 17,8 @@ import (
	"github.com/google/uuid"
)

var ctx = gomock.Any()

type FakeSpaceList struct{}

func (_ FakeSpaceList) List() (r []spaceType.Space) { return }


@@ 46,7 48,7 @@ func TestCreate(t *testing.T) {
		}
	)

	db.EXPECT().UserNew(uname, upass, upass).Return(u, nil).AnyTimes()
	db.EXPECT().UserNew(ctx, uname, upass, upass).Return(u, nil).AnyTimes()

	res, _ := http.PostForm(ts.URL+"/user/signup", form)
	assert.Equal(t, res.StatusCode, http.StatusOK)


@@ 73,7 75,7 @@ func TestLogin(t *testing.T) {
		}
	)

	db.EXPECT().UserGet(uname, upass).Return(u, nil).AnyTimes()
	db.EXPECT().UserGet(ctx, uname, upass).Return(u, nil).AnyTimes()

	res, _ := http.PostForm(ts.URL+"/user/login", form)
	assert.Equal(t, res.StatusCode, http.StatusOK)


@@ 120,9 122,9 @@ func TestHome(t *testing.T) {
		sl = FakeSpaceList{}
	)

	db.EXPECT().UserNew(uname, upass, upass).Return(u, nil).AnyTimes()
	db.EXPECT().UserGet(uname, upass).Return(u, nil).AnyTimes()
	db.EXPECT().SpacesPerUser(u, 0).Return(sl, nil).AnyTimes()
	db.EXPECT().UserNew(ctx, uname, upass, upass).Return(u, nil).AnyTimes()
	db.EXPECT().UserGet(ctx, uname, upass).Return(u, nil).AnyTimes()
	db.EXPECT().SpacesPerUser(ctx, u, 0).Return(sl, nil).AnyTimes()

	res, _ := http.PostForm(ts.URL+"/user/signup", form)
	assert.Equal(t, res.StatusCode, http.StatusOK)


@@ 154,7 156,7 @@ func TestBadLogin(t *testing.T) {
		}
	)

	db.EXPECT().UserGet(uname, upass).Return(nil, c.ErrNoLogin).AnyTimes()
	db.EXPECT().UserGet(ctx, uname, upass).Return(nil, c.ErrNoLogin).AnyTimes()

	res, _ := http.PostForm(ts.URL+"/user/login", form)
	assert.Equal(t, res.StatusCode, http.StatusBadRequest)


@@ 182,7 184,7 @@ func TestNoSignups(t *testing.T) {
		}
	)

	db.EXPECT().UserNew(uname, upass, upass).Return(nil, user.ErrNoSignup).AnyTimes()
	db.EXPECT().UserNew(ctx, uname, upass, upass).Return(nil, user.ErrNoSignup).AnyTimes()

	res, _ := http.PostForm(ts.URL+"/user/signup", form)
	assert.Equal(t, res.StatusCode, http.StatusForbidden)


@@ 211,8 213,8 @@ func TestCreatePaid(t *testing.T) {
		}
	)

	db.EXPECT().UserNew(uname, upass, upass).Return(u, nil).AnyTimes()
	stripe.EXPECT().StartCheckout(u, tier.Business).Return("SomeSessionID", "SomePublicKey", nil).AnyTimes()
	db.EXPECT().UserNew(ctx, uname, upass, upass).Return(u, nil).AnyTimes()
	stripe.EXPECT().StartCheckout(ctx, u, tier.Business).Return("SomeSessionID", "SomePublicKey", nil).AnyTimes()

	res, _ := http.PostForm(ts.URL+"/user/signup", form)
	assert.Equal(t, res.StatusCode, http.StatusOK)


@@ 243,9 245,9 @@ func TestHomeNoUser(t *testing.T) {
		sl = FakeSpaceList{}
	)

	db.EXPECT().UserNew(uname, upass, upass).Return(u, nil).AnyTimes()
	db.EXPECT().UserGet(uname, upass).Return(u, nil).AnyTimes()
	db.EXPECT().SpacesPerUser(u, 0).Return(sl, nil).AnyTimes()
	db.EXPECT().UserNew(ctx, uname, upass, upass).Return(u, nil).AnyTimes()
	db.EXPECT().UserGet(ctx, uname, upass).Return(u, nil).AnyTimes()
	db.EXPECT().SpacesPerUser(ctx, u, 0).Return(sl, nil).AnyTimes()

	res, _ := http.PostForm(ts.URL+"/user/signup", form)
	assert.Equal(t, res.StatusCode, http.StatusOK)