Skip to content

Commit

Permalink
api-120 validate test
Browse files Browse the repository at this point in the history
  • Loading branch information
upmkrasiukov committed Sep 19, 2024
1 parent 5c73b57 commit 9bc069b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion feed/updates.rss
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<description>Test description</description>
<pubDate>Tue, 17 Sep 2024 20:00:00 +0000</pubDate>
<link>https://docs.upvest.co/news#version-1350-release</link>
<guid>https://docs.upvest.co/news#version-1350-release-3</guid>
<guid>https://docs.upvest.co/news#version-1350-release-5</guid>
</item>
<item>
<title>v1.35.2 Another one</title>
Expand Down
22 changes: 11 additions & 11 deletions scripts/verify_rss.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,28 +72,28 @@ func (r *RSS) Validate() error {
func (r *RSS) validatePubDate() error {
err := validateRSSDate(r.Channel.PubDate)
if err != nil {
return fmt.Errorf("invalid publication channel date format in %s", r.Channel.PubDate)
return fmt.Errorf("channel pub date: %v", err)
}
return nil
}

func (r *RSS) validateItemGUIDs() error {
guids := make(map[string]bool)
func (r *RSS) validateItemDates() error {
for _, item := range r.Channel.Items {
if guids[item.GUID] {
return fmt.Errorf("duplicate GUID found: %s", item.GUID)
err := validateRSSDate(item.PubDate)
if err != nil {
return fmt.Errorf("item '%s' pub date: %v", item.Title, err)
}
guids[item.GUID] = true
}
return nil
}

func (r *RSS) validateItemDates() error {
func (r *RSS) validateItemGUIDs() error {
guids := make(map[string]bool)
for _, item := range r.Channel.Items {
err := validateRSSDate(item.PubDate)
if err != nil {
return fmt.Errorf("invalid date format in item '%s'", item.Title)
if guids[item.GUID] {
return fmt.Errorf("duplicate GUID found: %s", item.GUID)
}
guids[item.GUID] = true
}
return nil
}
Expand Down Expand Up @@ -124,7 +124,7 @@ func (r *RSS) validatePubDateUpdated() error {
func validateRSSDate(str string) error {
t, err := time.Parse(time.RFC1123Z, str)
if err != nil {
return fmt.Errorf("invalid publication channel date format in %s", str)
return fmt.Errorf("invalid date format in %s", str)
}
// Check that day of week was set correctly, as it is ignored by time.Parse.
if str != t.Format(time.RFC1123Z) {
Expand Down

0 comments on commit 9bc069b

Please sign in to comment.