repos / pico

pico services - prose.sh, pastes.sh, imgs.sh, feeds.sh, pgs.sh
git clone https://github.com/picosh/pico.git

pico / db / stub
Eric Bower · 16 Oct 24

stub.go

  1package stub
  2
  3import (
  4	"database/sql"
  5	"fmt"
  6	"log/slog"
  7	"time"
  8
  9	"github.com/picosh/pico/db"
 10)
 11
 12type StubDB struct {
 13	Logger *slog.Logger
 14}
 15
 16var _ db.DB = (*StubDB)(nil)
 17
 18func NewStubDB(logger *slog.Logger) *StubDB {
 19	d := &StubDB{
 20		Logger: logger,
 21	}
 22	d.Logger.Info("Connecting to test database")
 23	return d
 24}
 25
 26var notImpl = fmt.Errorf("not implemented")
 27
 28func (me *StubDB) RegisterUser(username, pubkey, comment string) (*db.User, error) {
 29	return nil, notImpl
 30}
 31
 32func (me *StubDB) RemoveUsers(userIDs []string) error {
 33	return notImpl
 34}
 35
 36func (me *StubDB) InsertPublicKey(userID, key, name string, tx *sql.Tx) error {
 37	return notImpl
 38}
 39
 40func (me *StubDB) UpdatePublicKey(pubkeyID, name string) (*db.PublicKey, error) {
 41	return nil, notImpl
 42}
 43
 44func (me *StubDB) FindPublicKeyForKey(key string) (*db.PublicKey, error) {
 45	return nil, notImpl
 46}
 47
 48func (me *StubDB) FindPublicKey(pubkeyID string) (*db.PublicKey, error) {
 49	return nil, notImpl
 50}
 51
 52func (me *StubDB) FindKeysForUser(user *db.User) ([]*db.PublicKey, error) {
 53	return []*db.PublicKey{}, notImpl
 54}
 55
 56func (me *StubDB) RemoveKeys(keyIDs []string) error {
 57	return notImpl
 58}
 59
 60func (me *StubDB) FindSiteAnalytics(space string) (*db.Analytics, error) {
 61	return nil, notImpl
 62}
 63
 64func (me *StubDB) FindPostsBeforeDate(date *time.Time, space string) ([]*db.Post, error) {
 65	return []*db.Post{}, notImpl
 66}
 67
 68func (me *StubDB) FindUserForKey(username string, key string) (*db.User, error) {
 69	return nil, notImpl
 70}
 71
 72func (me *StubDB) FindUser(userID string) (*db.User, error) {
 73	return nil, notImpl
 74}
 75
 76func (me *StubDB) ValidateName(name string) (bool, error) {
 77	return false, notImpl
 78}
 79
 80func (me *StubDB) FindUserForName(name string) (*db.User, error) {
 81	return nil, notImpl
 82}
 83
 84func (me *StubDB) FindUserForNameAndKey(name string, key string) (*db.User, error) {
 85	return nil, notImpl
 86}
 87
 88func (me *StubDB) FindUserForToken(token string) (*db.User, error) {
 89	return nil, notImpl
 90}
 91
 92func (me *StubDB) SetUserName(userID string, name string) error {
 93	return notImpl
 94}
 95
 96func (me *StubDB) FindPostWithFilename(filename string, persona_id string, space string) (*db.Post, error) {
 97	return nil, notImpl
 98}
 99
100func (me *StubDB) FindPostWithSlug(slug string, user_id string, space string) (*db.Post, error) {
101	return nil, notImpl
102}
103
104func (me *StubDB) FindPost(postID string) (*db.Post, error) {
105	return nil, notImpl
106}
107
108func (me *StubDB) FindAllPosts(page *db.Pager, space string) (*db.Paginate[*db.Post], error) {
109	return &db.Paginate[*db.Post]{}, notImpl
110}
111
112func (me *StubDB) FindAllUpdatedPosts(page *db.Pager, space string) (*db.Paginate[*db.Post], error) {
113	return &db.Paginate[*db.Post]{}, notImpl
114}
115
116func (me *StubDB) InsertPost(post *db.Post) (*db.Post, error) {
117	return nil, notImpl
118}
119
120func (me *StubDB) UpdatePost(post *db.Post) (*db.Post, error) {
121	return nil, notImpl
122}
123
124func (me *StubDB) RemovePosts(postIDs []string) error {
125	return notImpl
126}
127
128func (me *StubDB) FindPostsForUser(page *db.Pager, userID string, space string) (*db.Paginate[*db.Post], error) {
129	return &db.Paginate[*db.Post]{}, notImpl
130}
131
132func (me *StubDB) FindAllPostsForUser(userID string, space string) ([]*db.Post, error) {
133	return []*db.Post{}, notImpl
134}
135
136func (me *StubDB) FindPosts() ([]*db.Post, error) {
137	return []*db.Post{}, notImpl
138}
139
140func (me *StubDB) FindExpiredPosts(space string) ([]*db.Post, error) {
141	return []*db.Post{}, notImpl
142}
143
144func (me *StubDB) FindUpdatedPostsForUser(userID string, space string) ([]*db.Post, error) {
145	return []*db.Post{}, notImpl
146}
147
148func (me *StubDB) Close() error {
149	return notImpl
150}
151
152func (me *StubDB) InsertVisit(view *db.AnalyticsVisits) error {
153	return notImpl
154}
155
156func (me *StubDB) VisitSummary(opts *db.SummaryOpts) (*db.SummaryVisits, error) {
157	return &db.SummaryVisits{}, notImpl
158}
159
160func (me *StubDB) FindUsers() ([]*db.User, error) {
161	return []*db.User{}, notImpl
162}
163
164func (me *StubDB) ReplaceTagsForPost(tags []string, postID string) error {
165	return notImpl
166}
167
168func (me *StubDB) ReplaceAliasesForPost(aliases []string, postID string) error {
169	return notImpl
170}
171
172func (me *StubDB) FindUserPostsByTag(page *db.Pager, tag, userID, space string) (*db.Paginate[*db.Post], error) {
173	return &db.Paginate[*db.Post]{}, notImpl
174}
175
176func (me *StubDB) FindPostsByTag(pager *db.Pager, tag, space string) (*db.Paginate[*db.Post], error) {
177	return &db.Paginate[*db.Post]{}, notImpl
178}
179
180func (me *StubDB) FindPopularTags(space string) ([]string, error) {
181	return []string{}, notImpl
182}
183
184func (me *StubDB) FindTagsForPost(postID string) ([]string, error) {
185	return []string{}, notImpl
186}
187
188func (me *StubDB) FindFeatureForUser(userID string, feature string) (*db.FeatureFlag, error) {
189	return nil, notImpl
190}
191
192func (me *StubDB) FindFeaturesForUser(userID string) ([]*db.FeatureFlag, error) {
193	return []*db.FeatureFlag{}, notImpl
194}
195
196func (me *StubDB) HasFeatureForUser(userID string, feature string) bool {
197	return false
198}
199
200func (me *StubDB) FindTotalSizeForUser(userID string) (int, error) {
201	return 0, notImpl
202}
203
204func (me *StubDB) InsertFeedItems(postID string, items []*db.FeedItem) error {
205	return notImpl
206}
207
208func (me *StubDB) FindFeedItemsByPostID(postID string) ([]*db.FeedItem, error) {
209	return []*db.FeedItem{}, notImpl
210}
211
212func (me *StubDB) InsertProject(userID, name, projectDir string) (string, error) {
213	return "", notImpl
214}
215
216func (me *StubDB) UpdateProject(userID, name string) error {
217	return notImpl
218}
219
220func (me *StubDB) UpdateProjectAcl(userID, name string, acl db.ProjectAcl) error {
221	return notImpl
222}
223
224func (me *StubDB) LinkToProject(userID, projectID, projectDir string, commit bool) error {
225	return notImpl
226}
227
228func (me *StubDB) RemoveProject(projectID string) error {
229	return notImpl
230}
231
232func (me *StubDB) FindProjectByName(userID, name string) (*db.Project, error) {
233	return &db.Project{}, notImpl
234}
235
236func (me *StubDB) FindProjectLinks(userID, name string) ([]*db.Project, error) {
237	return []*db.Project{}, notImpl
238}
239
240func (me *StubDB) FindProjectsByPrefix(userID, prefix string) ([]*db.Project, error) {
241	return []*db.Project{}, notImpl
242}
243
244func (me *StubDB) FindProjectsByUser(userID string) ([]*db.Project, error) {
245	return []*db.Project{}, notImpl
246}
247
248func (me *StubDB) FindAllProjects(page *db.Pager, by string) (*db.Paginate[*db.Project], error) {
249	return &db.Paginate[*db.Project]{}, notImpl
250}
251
252func (me *StubDB) InsertToken(userID, name string) (string, error) {
253	return "", notImpl
254}
255
256func (me *StubDB) UpsertToken(userID, name string) (string, error) {
257	return "", notImpl
258}
259
260func (me *StubDB) FindTokenByName(userID, name string) (string, error) {
261	return "", notImpl
262}
263
264func (me *StubDB) RemoveToken(tokenID string) error {
265	return notImpl
266}
267
268func (me *StubDB) FindTokensForUser(userID string) ([]*db.Token, error) {
269	return []*db.Token{}, notImpl
270}
271
272func (me *StubDB) InsertFeature(userID, name string, expiresAt time.Time) (*db.FeatureFlag, error) {
273	return nil, notImpl
274}
275
276func (me *StubDB) RemoveFeature(userID string, name string) error {
277	return notImpl
278}
279
280func (me *StubDB) AddPicoPlusUser(username, paymentType, txId string) error {
281	return notImpl
282}