32 lines
764 B
Go
32 lines
764 B
Go
package input_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"git.jamestombleson.com/jtom38/newsbot-api/internal/domain"
|
|
"git.jamestombleson.com/jtom38/newsbot-api/internal/services/input"
|
|
)
|
|
|
|
var RedditRecord domain.SourceEntity = domain.SourceEntity{
|
|
ID: 999,
|
|
DisplayName: "dadjokes",
|
|
Source: domain.SourceCollectorReddit,
|
|
Url: "https://reddit.com/r/dadjokes",
|
|
Tags: "reddit, dadjokes",
|
|
}
|
|
|
|
func TestGetContent(t *testing.T) {
|
|
//This test is flaky right now due to the http changes in 1.17
|
|
rc := input.NewRedditClient(RedditRecord)
|
|
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")
|
|
}
|
|
}
|
|
}
|