2019-12-23 07:18:21 +01:00
|
|
|
// Copyright 2019 Frédéric Guillot. All rights reserved.
|
2017-11-20 06:10:04 +01:00
|
|
|
// Use of this source code is governed by the Apache 2.0
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
2018-08-25 06:51:50 +02:00
|
|
|
package atom // import "miniflux.app/reader/atom"
|
2017-11-20 06:10:04 +01:00
|
|
|
|
|
|
|
import (
|
|
|
|
"bytes"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
2019-12-23 07:18:21 +01:00
|
|
|
func TestDetectAtom10(t *testing.T) {
|
2017-11-20 06:10:04 +01: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 07:18:21 +01:00
|
|
|
version := getAtomFeedVersion(bytes.NewBufferString(data))
|
|
|
|
if version != "1.0" {
|
|
|
|
t.Errorf(`Invalid Atom version detected: %s`, version)
|
2017-11-20 06:10:04 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-12-23 07:18:21 +01:00
|
|
|
func TestDetectAtom03(t *testing.T) {
|
2017-11-20 06:10:04 +01:00
|
|
|
data := `<?xml version="1.0" encoding="utf-8"?>
|
2019-12-23 07:18:21 +01: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 06:10:04 +01:00
|
|
|
<entry>
|
2019-12-23 07:18:21 +01: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 06:10:04 +01:00
|
|
|
</entry>
|
2018-07-18 06:52:05 +02:00
|
|
|
</feed>`
|
|
|
|
|
2019-12-23 07:18:21 +01:00
|
|
|
version := getAtomFeedVersion(bytes.NewBufferString(data))
|
|
|
|
if version != "0.3" {
|
|
|
|
t.Errorf(`Invalid Atom version detected: %s`, version)
|
2019-12-23 02:47:56 +01:00
|
|
|
}
|
|
|
|
}
|