Exemple #1
0
func TestFetchUser(t *testing.T) {
	for i, testcase := range fetchtest {
		user, err := gowall.FetchUser(testcase.in)
		if err != nil {
			t.Errorf("%s", i, err)
		}
		if !reflect.DeepEqual(user, testcase.expected) {
			t.Errorf("%+v != %+v", i, testcase.expected, user)
		}
	}
}
Exemple #2
0
func main() {
	user, err := gowall.FetchUser("NickPresta")
	if err != nil {
		fmt.Println(err)
		return
	}

	fmt.Printf("Name: %s (%s)\n", user.Name, user.Username)
	fmt.Println("Location:", user.Location)
	fmt.Println("Endorsements:", user.Endorsements)
	fmt.Println("Team:", user.Team)

	fmt.Printf("\nAccounts (%d):\n", len(user.Accounts))
	for account, name := range user.Accounts {
		fmt.Printf("\t%s: %s\n", account, name)
	}

	fmt.Printf("\nBadges (%d):\n", len(user.Badges))
	for _, badge := range user.Badges {
		fmt.Printf("\t%s on %s\n", badge.Name, badge.Created)
	}
}
Exemple #3
0
func TestFetchUserDoesNotExist(t *testing.T) {
	_, err := gowall.FetchUser("thisuserdoesnotexistandshouldneverexisthopefully")
	if err == nil {
		t.Errorf("FetchUser() should have returned with an error.")
	}
}