auth

Paddy 2015-01-14 Parent:5bd46746b809 Child:e000b1c24fc0

115:fa8ee6a4507c Go to Latest

auth/client_test.go

Turn AddEndpoint into AddEndpoints. Because one is a special case of many, it makes sense to be able to add multiple endpoints in a single call to the database. So we've converted the AddEndpoint method into an AddEndpoints method and updated our tests appropriately. We also filled in the errors when creating a client through the API, and moved things around to optimize for the maximum number of errors returned in a single call.

History
     1.1 --- a/client_test.go	Sat Jan 10 04:16:07 2015 -0500
     1.2 +++ b/client_test.go	Wed Jan 14 00:23:30 2015 -0500
     1.3 @@ -155,7 +155,7 @@
     1.4  		if err != nil {
     1.5  			t.Fatalf("Error saving client to %T: %s", store, err)
     1.6  		}
     1.7 -		err = store.addEndpoint(client.ID, endpoint1)
     1.8 +		err = store.addEndpoints(client.ID, []Endpoint{endpoint1})
     1.9  		if err != nil {
    1.10  			t.Fatalf("Error adding endpoint to client in %T: %s", store, err)
    1.11  		}
    1.12 @@ -170,7 +170,7 @@
    1.13  		if !success {
    1.14  			t.Fatalf("Expected field %s to be %v, but %T returned %v", field, expectation, store, result)
    1.15  		}
    1.16 -		err = store.addEndpoint(client.ID, endpoint2)
    1.17 +		err = store.addEndpoints(client.ID, []Endpoint{endpoint2})
    1.18  		if err != nil {
    1.19  			t.Fatalf("Error adding endpoint to client in %T: %s", store, err)
    1.20  		}
    1.21 @@ -331,11 +331,11 @@
    1.22  		if err != nil {
    1.23  			t.Fatalf("Error saving client in %T: %s", store, err)
    1.24  		}
    1.25 -		err = store.addEndpoint(client.ID, endpoint1)
    1.26 +		err = store.addEndpoints(client.ID, []Endpoint{endpoint1})
    1.27  		if err != nil {
    1.28  			t.Fatalf("Error saving endpoint in %T: %s", store, err)
    1.29  		}
    1.30 -		err = store.addEndpoint(client.ID, endpoint2)
    1.31 +		err = store.addEndpoints(client.ID, []Endpoint{endpoint2})
    1.32  		if err != nil {
    1.33  			t.Fatalf("Error saving endpoint in %T: %s", store, err)
    1.34  		}
    1.35 @@ -393,11 +393,11 @@
    1.36  		if err != nil {
    1.37  			t.Fatalf("Error saving client in %T: %s", store, err)
    1.38  		}
    1.39 -		err = store.addEndpoint(client.ID, endpoint1)
    1.40 +		err = store.addEndpoints(client.ID, []Endpoint{endpoint1})
    1.41  		if err != nil {
    1.42  			t.Fatalf("Error saving endpoint in %T: %s", store, err)
    1.43  		}
    1.44 -		err = store.addEndpoint(client.ID, endpoint2)
    1.45 +		err = store.addEndpoints(client.ID, []Endpoint{endpoint2})
    1.46  		if err != nil {
    1.47  			t.Fatalf("Error saving endpoint in %T: %s", store, err)
    1.48  		}