auth

Paddy 2014-10-26 Parent:aff6863e3cb3

57:e45bfa2abc00 Go to Latest

auth/grant_test.go

The great documentation and exported interface cleanup. Modify all our *Store interfaces to be unexported, as there's no real good reason they need to be exported, especially as they can be implemented without being exported. The interfaces shouldn't matter to 99% of users of the package, so let's not pollute our package API. Further, all methods of the interfaces are now unexported, for pretty much the same reasoning. Add a doc.go file with documentation explaining the choices the package is making and what it provides. Implement documentation on all our exported types and methods and functions, which makes golint happy. The only remaining golint warning is about NewMemstore, which will stay the way it is. The memstore type is useful outside tests for things like standing up a server quickly when we don't care about the storage, and because the type is unexported, we _need_ a New function to create an instance that can be passed to the Context.

History
     1.1 --- a/grant_test.go	Wed Oct 22 00:30:28 2014 -0400
     1.2 +++ b/grant_test.go	Sun Oct 26 00:53:36 2014 -0400
     1.3 @@ -7,7 +7,7 @@
     1.4  	"code.secondbit.org/uuid"
     1.5  )
     1.6  
     1.7 -var grantStores = []GrantStore{NewMemstore()}
     1.8 +var grantStores = []grantStore{NewMemstore()}
     1.9  
    1.10  func compareGrants(grant1, grant2 Grant) (success bool, field string, grant1val, grant2val interface{}) {
    1.11  	if grant1.Code != grant2.Code {
    1.12 @@ -46,15 +46,15 @@
    1.13  		State:       "state",
    1.14  	}
    1.15  	for _, store := range grantStores {
    1.16 -		err := store.SaveGrant(grant)
    1.17 +		err := store.saveGrant(grant)
    1.18  		if err != nil {
    1.19  			t.Errorf("Error saving grant to %T: %s", store, err)
    1.20  		}
    1.21 -		err = store.SaveGrant(grant)
    1.22 +		err = store.saveGrant(grant)
    1.23  		if err != ErrGrantAlreadyExists {
    1.24  			t.Errorf("Expected ErrGrantAlreadyExists from %T, got %+v", store, err)
    1.25  		}
    1.26 -		retrieved, err := store.GetGrant(grant.Code)
    1.27 +		retrieved, err := store.getGrant(grant.Code)
    1.28  		if err != nil {
    1.29  			t.Errorf("Error retrieving grant from %T: %s", store, err)
    1.30  		}
    1.31 @@ -62,15 +62,15 @@
    1.32  		if !match {
    1.33  			t.Errorf("Expected `%v` in the `%s` field of grant retrieved from %T, got `%v`", expectation, field, store, result)
    1.34  		}
    1.35 -		err = store.DeleteGrant(grant.Code)
    1.36 +		err = store.deleteGrant(grant.Code)
    1.37  		if err != nil {
    1.38  			t.Errorf("Error removing grant from %T: %s", store, err)
    1.39  		}
    1.40 -		retrieved, err = store.GetGrant(grant.Code)
    1.41 +		retrieved, err = store.getGrant(grant.Code)
    1.42  		if err != ErrGrantNotFound {
    1.43  			t.Errorf("Expected ErrGrantNotFound from %T, got %+v and %+v", store, retrieved, err)
    1.44  		}
    1.45 -		err = store.DeleteGrant(grant.Code)
    1.46 +		err = store.deleteGrant(grant.Code)
    1.47  		if err != ErrGrantNotFound {
    1.48  			t.Errorf("Expected ErrGrantNotFound from %T, got %+v", store, err)
    1.49  		}