33 lines
724 B
Go
33 lines
724 B
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
)
|
|
|
|
type fakeST struct {
|
|
dept string
|
|
chapterID int64
|
|
err error
|
|
|
|
agents map[int64]int64 // userID → existing agent, 0 or absent = none
|
|
assigned map[int64]int64 // recorded writes
|
|
}
|
|
|
|
func (f *fakeST) ActiveAgent(ctx context.Context, userID int64) (int64, error) {
|
|
return f.agents[userID], nil
|
|
}
|
|
|
|
func (f *fakeST) AssignAgent(ctx context.Context, userID, agentID int64) error {
|
|
if f.assigned == nil {
|
|
f.assigned = map[int64]int64{}
|
|
}
|
|
f.assigned[userID] = agentID
|
|
return nil
|
|
}
|
|
|
|
func (f *fakeST) GetUser(ctx context.Context, id int64) (*User, error) {
|
|
if f.err != nil {
|
|
return nil, f.err
|
|
}
|
|
return &User{ID: id, ChapterID: f.chapterID, Department: f.dept}, nil
|
|
}
|