Adds sample test to check if URLs are validated

This commit is contained in:
Dennis Schoepf 2024-09-03 20:50:08 +02:00
parent a2c5560554
commit 9861d95009
2 changed files with 14 additions and 3 deletions

View file

@ -15,13 +15,13 @@ func Add(feedUrl string) error {
feed, err := parseByUrl(feedUrl)
// TODO: I have everything here (feed), might as well store it right away
// Add an article table that stores the feed data that is parsed here
if err != nil {
return err
}
// TODO: I have everything here (feed), might as well store it right away
// Add an article table that stores the feed data that is parsed here
f := database.Feed{
Name: feed.Title,
Url: feedUrl,

11
internal/feed_test.go Normal file
View file

@ -0,0 +1,11 @@
package feed
import "testing"
func TestAdd(t *testing.T) {
gotErr := Add("gibberish")
if gotErr == nil {
t.Errorf("Expected Add function to throw an error if an invalid URL is provided")
}
}