MCPcopy
hub / github.com/perkeep/perkeep / TestGetUserID

Function TestGetUserID

pkg/importer/twitter/twitter_test.go:37–56  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

35var ctxbg = context.Background()
36
37func TestGetUserID(t *testing.T) {
38 ctx, cancel := context.WithCancel(context.WithValue(context.TODO(), ctxutil.HTTPClient, &http.Client{
39 Transport: httputil.NewFakeTransport(map[string]func() *http.Response{
40 apiURL + userInfoAPIPath: httputil.FileResponder(filepath.FromSlash("testdata/verify_credentials-res.json")),
41 }),
42 }))
43 defer cancel()
44 inf, err := getUserInfo(importer.OAuthContext{Ctx: ctx, Client: &oauth.Client{}, Creds: &oauth.Credentials{}})
45 if err != nil {
46 t.Fatal(err)
47 }
48 want := userInfo{
49 ID: "2325935334",
50 ScreenName: "lejatorn",
51 Name: "Mathieu Lonjaret",
52 }
53 if inf != want {
54 t.Errorf("user info = %+v; want %+v", inf, want)
55 }
56}
57
58func checkTweets(t *testing.T, rc *importer.RunContext, expectedPostGroups ...map[string]string) {
59 postsNode, err := imptest.GetRequiredChildPathObj(rc.RootNode(), "tweets")

Callers

nothing calls this directly

Calls 4

NewFakeTransportFunction · 0.92
FileResponderFunction · 0.92
FatalMethod · 0.80
getUserInfoFunction · 0.70

Tested by

no test coverage detected