package openid import ( "bytes" "testing" ) func TestFindMetaXrdsLocation(t *testing.T) { searchMeta(t, ` `, "foo.com", false) searchMeta(t, ` `, "foo.com", false) } func TestMetaXrdsLocationOutsideHead(t *testing.T) { searchMeta(t, ` `, "", true) searchMeta(t, ` `, "", true) } func TestNoMetaXrdsLocation(t *testing.T) { searchMeta(t, ` `, "", true) } func searchMeta(t *testing.T, doc, loc string, err bool) { r := bytes.NewReader([]byte(doc)) res, e := findMetaXrdsLocation(r) if (e != nil) != err { t.Errorf("Unexpected error: '%s'", e) } else if e == nil { if res != loc { t.Errorf("Found bad location: Expected %s, Got %s", loc, res) } } }