

package foursquare

import (
	"net/http"
	"testing"

	"camlistore.org/pkg/context"
	"camlistore.org/pkg/httputil"
)

func TestGetUserId(t *testing.T) {
	im := &imp{}
	ctx := context.New(context.WithHTTPClient(&http.Client{
		Transport: httputil.NewFakeTransport(map[string]func() *http.Response{
			"https://api.foursquare.com/v2/users/self?oauth_token=footoken&v=20140225": httputil.FileResponder("testdata/users-me-res.json"),
		}),
	}))
	defer ctx.Cancel()
	inf, err := im.getUserInfo(ctx, "footoken")
	if err != nil {
		t.Fatal(err)
	}
	want := user{
		Id:        "13674",
		FirstName: "Brad",
		LastName:  "Fitzpatrick",
	}
	if inf != want {
		t.Errorf("user info = %+v; want %+v", inf, want)
	}
}
