fix vexing random test failures

so if it started with an e it'd fail. which is 1/16 of the time.

Change-Id: I253c8a34b6d34de59bf82a31df45b0bbe75529d3
This commit is contained in:
Stephen McQuay 2016-06-21 21:35:50 -07:00
parent b1d8ad5a6f
commit ffbc60d017
No known key found for this signature in database
GPG Key ID: 1ABF428F71BAFC3D

View File

@ -650,7 +650,7 @@ func TestRoundTrip(t *testing.T) {
if err != nil {
t.Fatalf("Failed to parse response body: %v", err)
}
tok := strings.TrimSpace(strings.Trim(string(bs), "new token: "))
tok := strings.TrimSpace(strings.TrimPrefix(string(bs), "new token: "))
u = fmt.Sprintf("%s/foo", ts.URL)
body := strings.NewReader(`{"repo": "https://s.mcquay.me/sm/vain"}`)
@ -724,7 +724,7 @@ func TestForgot(t *testing.T) {
if err != nil {
t.Fatalf("Failed to parse response body: %v", err)
}
iniTok := strings.Trim(string(bs), "new token: ")
iniTok := strings.TrimPrefix(string(bs), "new token: ")
//get new token for user (using forgot)
u = fmt.Sprintf("%s%s?email=fake@example.com", ts.URL, prefix["forgot"])
@ -742,7 +742,7 @@ func TestForgot(t *testing.T) {
if err != nil {
t.Fatalf("Failed to parse response body: %v", err)
}
recTok := strings.TrimSpace(strings.Trim(string(ft), "new token: "))
recTok := strings.TrimSpace(strings.TrimPrefix(string(ft), "new token: "))
if iniTok == recTok {
t.Fatalf("tokens should not be the same; old token %s, new token %s", iniTok, recTok)