Adds sample test to check if URLs are validated
This commit is contained in:
parent
a2c5560554
commit
9861d95009
2 changed files with 14 additions and 3 deletions
|
|
@ -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
11
internal/feed_test.go
Normal 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")
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue