// putUser204 validates updating a user that does exist.
putUser204 validates updating a user that does exist.
// putUser204 validates updating a user that does exist .
func putUser204(t *testing.T, id string) {
	body := `{"name": "Jacob Walker"}`
	r := httptest.NewRequest("PUT", "/v1/users/"+id, strings.NewReader(body))
	w := httptest.NewRecorder()
	r.Header.Set("Authorization", adminAuthorization)
	a.ServeHTTP(w, r)
	t.Log("Given the need to update a user with the users endpoint.")
	{
		t.Log("\tTest 0:\tWhen using the modified user value.")
		{
			if w.Code != http.StatusNoContent {
				t.Fatalf("\t%s\tShould receive a status code of 204 for the response : %v", tests.Failed, w.Code)
			}
			t.Logf("\t%s\tShould receive a status code of 204 for the response.", tests.Success)
			r = httptest.NewRequest("GET", "/v1/users/"+id, nil)
			w = httptest.NewRecorder()
			r.Header.Set("Authorization", adminAuthorization)
			a.ServeHTTP(w, r)
			if w.Code != http.StatusOK {
				t.Fatalf("\t%s\tShould receive a status code of 200 for the retrieve : %v", tests.Failed, w.Code)
			}
			t.Logf("\t%s\tShould receive a status code of 200 for the retrieve.", tests.Success)
			var ru user.User
			if err := json.NewDecoder(w.Body).Decode(&ru); err != nil {
				t.Fatalf("\t%s\tShould be able to unmarshal the response : %v", tests.Failed, err)
			}
			if ru.Name != "Jacob Walker" {
				t.Fatalf("\t%s\tShould see an updated Name : got %q want %q", tests.Failed, ru.Name, "Jacob Walker")
			}
			t.Logf("\t%s\tShould see an updated Name.", tests.Success)
			if ru.Email != "bill@ardanlabs.com" {
				t.Fatalf("\t%s\tShould not affect other fields like Email : got %q want %q", tests.Failed, ru.Email, "bill@ardanlabs.com")
			}
			t.Logf("\t%s\tShould not affect other fields like Email.", tests.Success)
		}
	}
}
func putUser204 ( t * testing . T , id string ) { body := `{"name": "Jacob Walker"}` r := httptest . NewRequest ( " " , " " + id , strings . NewReader ( body ) ) w := httptest . NewRecorder ( ) r . Header . Set ( " " , adminAuthorization ) a . ServeHTTP ( w , r ) t . Log ( " " ) { t . Log ( " \t \t " ) { if w . Code != http . StatusNoContent { t . Fatalf ( " \t \t " , tests . Failed , w . Code ) } t . Logf ( " \t \t " , tests . Success ) r = httptest . NewRequest ( " " , " " + id , nil ) w = httptest . NewRecorder ( ) r . Header . Set ( " " , adminAuthorization ) a . ServeHTTP ( w , r ) if w . Code != http . StatusOK { t . Fatalf ( " \t \t " , tests . Failed , w . Code ) } t . Logf ( " \t \t " , tests . Success ) var ru user . User if err := json . NewDecoder ( w . Body ) . Decode ( & ru ) ; err != nil { t . Fatalf ( " \t \t " , tests . Failed , err ) } if ru . Name != " " { t . Fatalf ( " \t \t " , tests . Failed , ru . Name , " " ) } t . Logf ( " \t \t " , tests . Success ) if ru . Email != " " { t . Fatalf ( " \t \t " , tests . Failed , ru . Email , " " ) } t . Logf ( " \t \t " , tests . Success ) } } }
putUser204 validates updating a user that does exist.
putUser204 validates updating a user that does exist .