Add HTTP /v1 MVC, TCP send path, groups with server-side member-avatar collage, object-storage upload, and friends/favorites around the architecture-v3 layout. Co-authored-by: Cursor <cursoragent@cursor.com>
37 lines
749 B
Go
37 lines
749 B
Go
package logic
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"spark-server/internal/infrastructure/id"
|
|
"spark-server/internal/module/user/model"
|
|
)
|
|
|
|
func testService(t *testing.T) (*Service, *model.MemoryRepo, *model.MemoryCodes) {
|
|
t.Helper()
|
|
ids, err := id.New(1)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
repo := model.NewMemoryRepo()
|
|
codes := model.NewMemoryCodes()
|
|
return NewService(repo, codes, ids, newMemObjects()), repo, codes
|
|
}
|
|
|
|
type memObjects struct {
|
|
kv map[string][]byte
|
|
}
|
|
|
|
func newMemObjects() *memObjects {
|
|
return &memObjects{kv: map[string][]byte{}}
|
|
}
|
|
|
|
func (m *memObjects) Put(_ context.Context, key string, body []byte, _ string) error {
|
|
if m.kv == nil {
|
|
m.kv = map[string][]byte{}
|
|
}
|
|
m.kv[key] = append([]byte(nil), body...)
|
|
return nil
|
|
}
|