scopes
2015-12-13
Parent:b93938562a17
scopes/scope.go
Port over Postgres storage and tests. Do the minimum possible port of the code from auth to get Postgres working and make the tests run and pass again. This leaves a bug where the ErrScopeAlreadyExists type, when populatd from Postgres, contains the entire error string returned from the database, instead of parsing the ID itself out. Which is a thing we should do and add a test for.
1 package scopes
3 import (
4 "errors"
5 "fmt"
7 "code.secondbit.org/scopes.hg/types"
9 "golang.org/x/net/context"
10 )
12 var (
13 ErrNoStorer = errors.New("Storer not set in Context")
14 ErrScopeNotFound = errors.New("Scope not found")
15 )
17 type ErrScopeAlreadyExists string
19 func (e ErrScopeAlreadyExists) Error() string {
20 return fmt.Sprintf("scope %s already exists", string(e))
21 }
23 type Storer interface {
24 CreateScopes(scopes []scopeTypes.Scope, ctx context.Context) error
25 GetScopes(ids []string, ctx context.Context) (map[string]scopeTypes.Scope, error)
26 UpdateScope(change scopeTypes.ScopeChange, ctx context.Context) error
27 RemoveScopes(ids []string, ctx context.Context) error
28 ListScopes(ctx context.Context) ([]scopeTypes.Scope, error)
29 }