1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-12-09 19:56:44 -05:00
v2fly/testing/mocks/mockuserset.go
2015-09-14 19:03:31 +02:00

24 lines
430 B
Go

package mocks
import (
"github.com/v2ray/v2ray-core"
)
type MockUserSet struct {
UserIds []core.ID
UserHashes map[string]int
}
func (us *MockUserSet) AddUser(user core.User) error {
us.UserIds = append(us.UserIds, user.Id)
return nil
}
func (us *MockUserSet) GetUser(userhash []byte) (*core.ID, bool) {
idx, found := us.UserHashes[string(userhash)]
if found {
return &us.UserIds[idx], true
}
return nil, false
}