Tests are working again

This commit is contained in:
Jonathan Leibiusky @xetorthio
2017-07-28 20:42:05 -03:00
parent 91c7ec3bd5
commit 0e08107738
44 changed files with 1640 additions and 1595 deletions

View File

@@ -48,27 +48,12 @@ func (store *storage) SessionPut(s *types.Session) error {
return store.save()
}
func (store *storage) InstanceFindByIP(ip string) (*types.Instance, error) {
store.rw.Lock()
defer store.rw.Unlock()
for _, s := range store.db {
for _, i := range s.Instances {
if i.IP == ip {
return i, nil
}
}
}
return nil, fmt.Errorf("%s", notFound)
}
func (store *storage) InstanceFindByIPAndSession(sessionPrefix, ip string) (*types.Instance, error) {
func (store *storage) InstanceFind(sessionId, ip string) (*types.Instance, error) {
store.rw.Lock()
defer store.rw.Unlock()
for id, s := range store.db {
if strings.HasPrefix(id, sessionPrefix) {
if strings.HasPrefix(id, sessionId[:8]) {
for _, i := range s.Instances {
if i.IP == ip {
return i, nil
@@ -80,23 +65,6 @@ func (store *storage) InstanceFindByIPAndSession(sessionPrefix, ip string) (*typ
return nil, fmt.Errorf("%s", notFound)
}
func (store *storage) InstanceFindByAlias(sessionPrefix, alias string) (*types.Instance, error) {
store.rw.Lock()
defer store.rw.Unlock()
for id, s := range store.db {
if strings.HasPrefix(id, sessionPrefix) {
for _, i := range s.Instances {
if i.Alias == alias {
return i, nil
}
}
}
}
return nil, fmt.Errorf("%s", notFound)
}
func (store *storage) InstanceCreate(sessionId string, instance *types.Instance) error {
store.rw.Lock()
defer store.rw.Unlock()