2023-06-19 17:42:47 -04:00
|
|
|
// SPDX-FileCopyrightText: Copyright The Miniflux Authors. All rights reserved.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0
|
2017-11-20 00:10:04 -05:00
|
|
|
|
2023-08-10 22:46:45 -04:00
|
|
|
package atom // import "miniflux.app/v2/internal/reader/atom"
|
2017-11-20 00:10:04 -05:00
|
|
|
|
|
|
|
import (
|
|
|
|
"bytes"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
2019-12-23 01:18:21 -05:00
|
|
|
func TestDetectAtom10(t *testing.T) {
|
2017-11-20 00:10:04 -05:00
|
|
|
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>`
|
|
|
|
|
2019-12-23 01:18:21 -05:00
|
|
|
version := getAtomFeedVersion(bytes.NewBufferString(data))
|
|
|
|
if version != "1.0" {
|
|
|
|
t.Errorf(`Invalid Atom version detected: %s`, version)
|
2017-11-20 00:10:04 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-12-23 01:18:21 -05:00
|
|
|
func TestDetectAtom03(t *testing.T) {
|
2017-11-20 00:10:04 -05:00
|
|
|
data := `<?xml version="1.0" encoding="utf-8"?>
|
2019-12-23 01:18:21 -05:00
|
|
|
<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>
|
2017-11-20 00:10:04 -05:00
|
|
|
<entry>
|
2019-12-23 01:18:21 -05:00
|
|
|
<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>
|
2017-11-20 00:10:04 -05:00
|
|
|
</entry>
|
2018-07-18 00:52:05 -04:00
|
|
|
</feed>`
|
|
|
|
|
2019-12-23 01:18:21 -05:00
|
|
|
version := getAtomFeedVersion(bytes.NewBufferString(data))
|
|
|
|
if version != "0.3" {
|
|
|
|
t.Errorf(`Invalid Atom version detected: %s`, version)
|
2019-12-22 20:47:56 -05:00
|
|
|
}
|
|
|
|
}
|