scopes

Paddy 2015-12-13 Parent:b93938562a17

2:a64a25ae2db1 Go to Latest

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.

History
     1.1 --- a/scope.go	Sat Dec 05 15:00:34 2015 -0800
     1.2 +++ b/scope.go	Sun Dec 13 20:42:48 2015 -0800
     1.3 @@ -20,14 +20,6 @@
     1.4  	return fmt.Sprintf("scope %s already exists", string(e))
     1.5  }
     1.6  
     1.7 -func stringsToScopes(s []string) scopeTypes.Scopes {
     1.8 -	res := make(scopeTypes.Scopes, len(s))
     1.9 -	for pos, scope := range s {
    1.10 -		res[pos] = scopeTypes.Scope{ID: scope}
    1.11 -	}
    1.12 -	return res
    1.13 -}
    1.14 -
    1.15  type Storer interface {
    1.16  	CreateScopes(scopes []scopeTypes.Scope, ctx context.Context) error
    1.17  	GetScopes(ids []string, ctx context.Context) (map[string]scopeTypes.Scope, error)