Exemple #1
0
func TestBadToken(t *testing.T) {
	expected := http.StatusForbidden
	status, _ := client.UserDetails(cfg.Endpoint, goodUser, badToken)
	if status != expected {
		t.Fatalf("Expected %v, got %v\n", expected, status)
	}
}
Exemple #2
0
func TestBadUser(t *testing.T) {
	expected := http.StatusNotFound
	status, _ := client.UserDetails(cfg.Endpoint, badUser, goodToken)
	if status != expected {
		t.Fatalf("Expected %v, got %v\n", expected, status)
	}
}
Exemple #3
0
func TestEmptyToken(t *testing.T) {
	expected := http.StatusBadRequest
	status, _ := client.UserDetails(cfg.Endpoint, goodUser, empty)
	if status != expected {
		t.Fatalf("Expected %v, got %v\n", expected, status)
	}
}
Exemple #4
0
func TestHappyDay(t *testing.T) {
	expected := http.StatusOK
	status, user := client.UserDetails(cfg.Endpoint, goodUser, goodToken)
	if status != expected {
		t.Fatalf("Expected %v, got %v\n", expected, status)
	}

	if user == nil {
		t.Fatalf("Expected to find user %v and did not\n", goodUser)
	}

	if emptyField(user.UserId) ||
		emptyField(user.DisplayName) ||
		emptyField(user.FirstName) ||
		emptyField(user.Initials) ||
		emptyField(user.LastName) ||
		emptyField(user.Description) ||
		emptyField(user.Department) ||
		emptyField(user.Title) ||
		emptyField(user.Office) ||
		emptyField(user.Phone) ||
		emptyField(user.Email) {
		t.Fatalf("Expected non-empty field but one is empty\n")
	}
}