2022-06-30 14:54:58 -07:00
|
|
|
package input_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2024-05-09 18:59:50 -07:00
|
|
|
"git.jamestombleson.com/jtom38/newsbot-api/domain"
|
|
|
|
"git.jamestombleson.com/jtom38/newsbot-api/internal/entity"
|
2024-04-23 07:15:38 -07:00
|
|
|
"git.jamestombleson.com/jtom38/newsbot-api/internal/services/input"
|
2022-06-30 14:54:58 -07:00
|
|
|
)
|
|
|
|
|
2024-05-09 18:59:50 -07:00
|
|
|
var rssRecord = entity.SourceEntity{
|
2024-05-01 18:26:14 -07:00
|
|
|
ID: 1,
|
2024-04-28 10:02:57 -07:00
|
|
|
DisplayName: "ArsTechnica",
|
2024-05-01 18:26:14 -07:00
|
|
|
Url: "https://feeds.arstechnica.com/arstechnica/index",
|
|
|
|
Source: domain.SourceCollectorRss,
|
2022-06-30 14:54:58 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestRssClientConstructor(t *testing.T) {
|
|
|
|
input.NewRssClient(rssRecord)
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestRssGetFeed(t *testing.T) {
|
|
|
|
client := input.NewRssClient(rssRecord)
|
2024-05-01 17:49:38 -07:00
|
|
|
_, err := client.GetArticles()
|
2022-12-04 08:49:17 -08:00
|
|
|
if err != nil {
|
|
|
|
t.Error(err)
|
|
|
|
}
|
2024-05-01 17:49:38 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestRssAgainstGita(t *testing.T) {
|
2024-05-09 18:59:50 -07:00
|
|
|
client := input.NewRssClient(entity.SourceEntity{
|
2024-05-01 17:49:38 -07:00
|
|
|
ID: 2,
|
|
|
|
DisplayName: "Gitea - Newsbot-api",
|
|
|
|
Source: domain.SourceCollectorRss,
|
|
|
|
Url: "https://git.jamestombleson.com/jtom38/newsbot-api.rss",
|
|
|
|
Tags: "rss,gitea,newsbot-api",
|
|
|
|
})
|
|
|
|
_, err := client.GetArticles()
|
|
|
|
if err != nil {
|
|
|
|
t.Error(err)
|
2022-12-04 08:49:17 -08:00
|
|
|
}
|
2022-06-30 14:54:58 -07:00
|
|
|
|
2022-12-04 08:49:17 -08:00
|
|
|
}
|