oembed_test.go 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. package anaconda_test
  2. import (
  3. "net/url"
  4. "reflect"
  5. "testing"
  6. "github.com/ChimeraCoder/anaconda"
  7. )
  8. func TestOEmbed(t *testing.T) {
  9. // It is the only one that can be tested without auth
  10. // However, it is still rate-limited
  11. api := anaconda.NewTwitterApi("", "")
  12. api.SetBaseUrl(testBase)
  13. o, err := api.GetOEmbed(url.Values{"id": []string{"99530515043983360"}})
  14. if err != nil {
  15. t.Error(err)
  16. }
  17. if !reflect.DeepEqual(o, expectedOEmbed) {
  18. t.Errorf("Actual OEmbed differs expected:\n%#v\n Got: \n%#v\n", expectedOEmbed, o)
  19. }
  20. }
  21. var expectedOEmbed anaconda.OEmbed = anaconda.OEmbed{
  22. Cache_age: "3153600000",
  23. Url: "https://twitter.com/twitter/status/99530515043983360",
  24. Height: 0,
  25. Provider_url: "https://twitter.com",
  26. Provider_name: "Twitter",
  27. Author_name: "Twitter",
  28. Version: "1.0",
  29. Author_url: "https://twitter.com/twitter",
  30. Type: "rich",
  31. Html: `<blockquote class="twitter-tweet"><p lang="en" dir="ltr">Cool! “<a href="https://twitter.com/tw1tt3rart">@tw1tt3rart</a>: <a href="https://twitter.com/hashtag/TWITTERART?src=hash">#TWITTERART</a> ╱╱╱╱╱╱╱╱ ╱╱╭━━━━╮╱╱╭━━━━╮ ╱╱┃▇┆┆▇┃╱╭┫ⓦⓔⓔⓚ┃ ╱╱┃▽▽▽▽┃━╯┃♡ⓔⓝⓓ┃ ╱╭┫△△△△┣╮╱╰━━━━╯ ╱┃┃┆┆┆┆┃┃╱╱╱╱╱╱ ╱┗┫┆┏┓┆┣┛╱╱╱╱╱”</p>&mdash; Twitter (@twitter) <a href="https://twitter.com/twitter/status/99530515043983360">August 5, 2011</a></blockquote>
  32. <script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script>`,
  33. Width: 550,
  34. }