import_export_test.go 959 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. // Copyright 2018 Frédéric Guillot. All rights reserved.
  2. // Use of this source code is governed by the Apache 2.0
  3. // license that can be found in the LICENSE file.
  4. // +build integration
  5. package tests
  6. import (
  7. "bytes"
  8. "io/ioutil"
  9. "strings"
  10. "testing"
  11. )
  12. func TestExport(t *testing.T) {
  13. client := createClient(t)
  14. output, err := client.Export()
  15. if err != nil {
  16. t.Fatal(err)
  17. }
  18. if !strings.HasPrefix(string(output), "<?xml") {
  19. t.Fatalf(`Invalid OPML export, got "%s"`, string(output))
  20. }
  21. }
  22. func TestImport(t *testing.T) {
  23. client := createClient(t)
  24. data := `<?xml version="1.0" encoding="UTF-8"?>
  25. <opml version="2.0">
  26. <body>
  27. <outline text="Test Category">
  28. <outline title="Test" text="Test" xmlUrl="` + testFeedURL + `" htmlUrl="` + testWebsiteURL + `"></outline>
  29. </outline>
  30. </body>
  31. </opml>`
  32. b := bytes.NewReader([]byte(data))
  33. err := client.Import(ioutil.NopCloser(b))
  34. if err != nil {
  35. t.Fatal(err)
  36. }
  37. }