2022-06-30 14:54:58 -07:00
|
|
|
package input_test
|
2022-04-17 07:25:49 -07:00
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2024-05-01 18:26:14 -07:00
|
|
|
"git.jamestombleson.com/jtom38/newsbot-api/internal/domain"
|
2024-04-23 07:15:38 -07:00
|
|
|
"git.jamestombleson.com/jtom38/newsbot-api/internal/services/input"
|
2022-04-17 07:25:49 -07:00
|
|
|
)
|
|
|
|
|
2024-05-01 18:26:14 -07:00
|
|
|
var RedditRecord domain.SourceEntity = domain.SourceEntity{
|
|
|
|
ID: 9999,
|
|
|
|
DisplayName: "dadjokes",
|
|
|
|
Source: domain.SourceCollectorRss,
|
|
|
|
Url: "https://reddit.com/r/dadjokes",
|
|
|
|
Tags: "reddit, dadjokes",
|
2022-06-08 21:17:08 -07:00
|
|
|
}
|
|
|
|
|
2022-04-17 07:25:49 -07:00
|
|
|
func TestGetContent(t *testing.T) {
|
2022-04-29 13:02:25 -07:00
|
|
|
//This test is flaky right now due to the http changes in 1.17
|
2022-06-30 14:54:58 -07:00
|
|
|
rc := input.NewRedditClient(RedditRecord)
|
2022-06-08 21:17:08 -07:00
|
|
|
raw, err := rc.GetContent()
|
|
|
|
if err != nil {
|
|
|
|
t.Error(err)
|
|
|
|
}
|
|
|
|
redditArticles := rc.ConvertToArticles(raw)
|
|
|
|
for _, posts := range redditArticles {
|
|
|
|
if posts.Title == "" {
|
|
|
|
t.Error("Title is missing")
|
|
|
|
}
|
|
|
|
}
|
2022-12-04 08:49:17 -08:00
|
|
|
}
|