auth

Paddy 2015-03-21 Parent:b5432f50f057 Child:8267e1c8bcd1

148:06fb735031bb Go to Latest

auth/profile_test.go

Do a first, naive pass at storing profiles in Postgres. This is untested against an actual database. It's a best-guess attempt at SQL. It _should_ work. I think. Start storing things in Postgres, starting with Profiles and Logins. This necessitates the addition of a Deleted property to the Profile type, because I'm not deleting those in case of accidental deletion. Logins, though, we'll delete. This also necessitates updating the profileStore interface to no longer have a deleteProfile method, because we're tracking that through updates now. Then we need to update our profileStore tests, because they no longer clean up after themselves. Which, come to think of it, may cause some problems later.

History
     1.1 --- a/profile_test.go	Fri Mar 20 23:03:21 2015 -0400
     1.2 +++ b/profile_test.go	Sat Mar 21 01:23:33 2015 -0400
     1.3 @@ -60,6 +60,9 @@
     1.4  	if !profile1.LastSeen.Equal(profile2.LastSeen) {
     1.5  		return false, "last seen", profile1.LastSeen, profile2.LastSeen
     1.6  	}
     1.7 +	if profile1.Deleted != profile2.Deleted {
     1.8 +		return false, "deleted", profile1.Deleted, profile2.Deleted
     1.9 +	}
    1.10  	return true, "", nil, nil
    1.11  }
    1.12  
    1.13 @@ -116,7 +119,8 @@
    1.14  		if !match {
    1.15  			t.Errorf("Expected `%v` in the `%s` field of profile retrieved from %T, got `%v`", expectation, field, store, result)
    1.16  		}
    1.17 -		err = context.DeleteProfile(profile.ID)
    1.18 +		deleted := true
    1.19 +		err = context.UpdateProfile(profile.ID, ProfileChange{Deleted: &deleted})
    1.20  		if err != nil {
    1.21  			t.Errorf("Error removing profile from %T: %s", store, err)
    1.22  		}
    1.23 @@ -124,10 +128,6 @@
    1.24  		if err != ErrProfileNotFound {
    1.25  			t.Errorf("Expected ErrProfileNotFound from %T, got %+v and %+v", store, retrieved, err)
    1.26  		}
    1.27 -		err = context.DeleteProfile(profile.ID)
    1.28 -		if err != ErrProfileNotFound {
    1.29 -			t.Errorf("Expected ErrProfileNotFound from %T, got %+v", store, err)
    1.30 -		}
    1.31  	}
    1.32  }
    1.33  
    1.34 @@ -155,6 +155,7 @@
    1.35  		var passphraseScheme int
    1.36  		var compromised bool
    1.37  
    1.38 +		profile.ID = uuid.NewID()
    1.39  		change := ProfileChange{}
    1.40  		expectation := profile
    1.41  		result := profile
    1.42 @@ -231,14 +232,6 @@
    1.43  			if !match {
    1.44  				t.Errorf("Expected field `%s` to be `%v`, got `%v` from %T", field, expected, got, store)
    1.45  			}
    1.46 -			err = context.DeleteProfile(profile.ID)
    1.47 -			if err != nil {
    1.48 -				t.Errorf("Error deleting profile from %T: %s", store, err)
    1.49 -			}
    1.50 -			err = context.UpdateProfile(profile.ID, change)
    1.51 -			if err != ErrProfileNotFound {
    1.52 -				t.Errorf("Expected ErrProfileNotFound, got %v from %T", err, store)
    1.53 -			}
    1.54  		}
    1.55  	}
    1.56  }
    1.57 @@ -464,3 +457,4 @@
    1.58  
    1.59  // BUG(paddy): We need to test the validateNewProfileRequest helper.
    1.60  // BUG(paddy): We need to test the CreateProfileHandler.
    1.61 +// BUG(paddy): We need to test that deleting works as we expect.