import_export_test.go 971 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. //go:build integration
  5. // +build integration
  6. package tests
  7. import (
  8. "bytes"
  9. "io"
  10. "strings"
  11. "testing"
  12. )
  13. func TestExport(t *testing.T) {
  14. client := createClient(t)
  15. output, err := client.Export()
  16. if err != nil {
  17. t.Fatal(err)
  18. }
  19. if !strings.HasPrefix(string(output), "<?xml") {
  20. t.Fatalf(`Invalid OPML export, got "%s"`, string(output))
  21. }
  22. }
  23. func TestImport(t *testing.T) {
  24. client := createClient(t)
  25. data := `<?xml version="1.0" encoding="UTF-8"?>
  26. <opml version="2.0">
  27. <body>
  28. <outline text="Test Category">
  29. <outline title="Test" text="Test" xmlUrl="` + testFeedURL + `" htmlUrl="` + testWebsiteURL + `"></outline>
  30. </outline>
  31. </body>
  32. </opml>`
  33. b := bytes.NewReader([]byte(data))
  34. err := client.Import(io.NopCloser(b))
  35. if err != nil {
  36. t.Fatal(err)
  37. }
  38. }