| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- // SPDX-FileCopyrightText: Copyright The Miniflux Authors. All rights reserved.
- // SPDX-License-Identifier: Apache-2.0
- package atom // import "miniflux.app/v2/internal/reader/atom"
- import (
- "bytes"
- "testing"
- )
- func TestDetectAtom10(t *testing.T) {
- data := `<?xml version="1.0" encoding="utf-8"?>
- <feed xmlns="http://www.w3.org/2005/Atom">
- <title>Example Feed</title>
- <link href="http://example.org/"/>
- <updated>2003-12-13T18:30:02Z</updated>
- <author>
- <name>John Doe</name>
- </author>
- <id>urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6</id>
- <entry>
- <title>Atom-Powered Robots Run Amok</title>
- <link href="http://example.org/2003/12/13/atom03"/>
- <id>urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a</id>
- <updated>2003-12-13T18:30:02Z</updated>
- <summary>Some text.</summary>
- </entry>
- </feed>`
- version := getAtomFeedVersion(bytes.NewBufferString(data))
- if version != "1.0" {
- t.Errorf(`Invalid Atom version detected: %s`, version)
- }
- }
- func TestDetectAtom03(t *testing.T) {
- data := `<?xml version="1.0" encoding="utf-8"?>
- <feed version="0.3" xmlns="http://purl.org/atom/ns#">
- <title>dive into mark</title>
- <link rel="alternate" type="text/html" href="http://diveintomark.org/"/>
- <modified>2003-12-13T18:30:02Z</modified>
- <author><name>Mark Pilgrim</name></author>
- <entry>
- <title>Atom 0.3 snapshot</title>
- <link rel="alternate" type="text/html" href="http://diveintomark.org/2003/12/13/atom03"/>
- <id>tag:diveintomark.org,2003:3.2397</id>
- <issued>2003-12-13T08:29:29-04:00</issued>
- <modified>2003-12-13T18:30:02Z</modified>
- <summary type="text/plain">This is a test</summary>
- <content type="text/html" mode="escaped"><![CDATA[<p>HTML content</p>]]></content>
- </entry>
- </feed>`
- version := getAtomFeedVersion(bytes.NewBufferString(data))
- if version != "0.3" {
- t.Errorf(`Invalid Atom version detected: %s`, version)
- }
- }
|