2014-04-01 14:17:16 +00:00
|
|
|
/*
|
|
|
|
Copyright 2014 The Camlistore Authors
|
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
package picasa
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"camlistore.org/pkg/context"
|
|
|
|
"camlistore.org/pkg/test"
|
|
|
|
|
|
|
|
"camlistore.org/third_party/github.com/tgulacsi/picago"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestGetUserId(t *testing.T) {
|
|
|
|
userID := "11047045264"
|
2014-05-29 15:40:50 +00:00
|
|
|
responder := test.FileResponder("testdata/users-me-res.xml")
|
2014-07-02 21:34:24 +00:00
|
|
|
ctx := context.New(context.WithHTTPClient(&http.Client{
|
2014-04-01 14:17:16 +00:00
|
|
|
Transport: test.NewFakeTransport(map[string]func() *http.Response{
|
|
|
|
"https://picasaweb.google.com/data/feed/api/user/default/contacts?kind=user": responder,
|
|
|
|
"https://picasaweb.google.com/data/feed/api/user/" + userID + "/contacts?kind=user": responder,
|
|
|
|
}),
|
2014-07-02 21:34:24 +00:00
|
|
|
}))
|
|
|
|
defer ctx.Cancel()
|
2014-04-01 14:17:16 +00:00
|
|
|
inf, err := getUserInfo(ctx, "footoken")
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
want := picago.User{
|
|
|
|
ID: userID,
|
|
|
|
URI: "https://picasaweb.google.com/" + userID,
|
|
|
|
Name: "Tamás Gulácsi",
|
|
|
|
Thumbnail: "https://lh4.googleusercontent.com/-qqove344/AAAAAAAAAAI/AAAAAAABcbg/TXl3f2K9dzI/s64-c/11047045264.jpg",
|
|
|
|
}
|
|
|
|
if inf != want {
|
|
|
|
t.Errorf("user info = %+v; want %+v", inf, want)
|
|
|
|
}
|
|
|
|
}
|