diff --git a/src/feeds/db.go b/src/feeds/db.go index b3e60a4..f3f83f2 100644 --- a/src/feeds/db.go +++ b/src/feeds/db.go @@ -164,11 +164,14 @@ func oldGet(ctx context.Context, id string) (Feed, error) { return Feed{}, fmt.Errorf("%+v, %+v, %+v", entry, version, execution) } -func Executed(ctx context.Context, id string, version time.Time) error { +func (feed Feed) Executed(ctx context.Context) error { if err := initDB(ctx); err != nil { return err } + id := feed.Entry.ID + version := feed.Version.Created + now := time.Now() return db.Exec(ctx, ` INSERT INTO "feed.executions" ( @@ -208,11 +211,11 @@ func Insert(ctx context.Context, url, cron string) (string, error) { ) } -func Update(ctx context.Context, id string, url, cron *string) error { +func (feed Feed) Update(ctx context.Context, url, cron *string) error { return io.EOF } -func Delete(ctx context.Context, id string) error { +func (feed Feed) Delete(ctx context.Context) error { return io.EOF } diff --git a/src/feeds/db_test.go b/src/feeds/db_test.go index aabbd39..c57ee30 100644 --- a/src/feeds/db_test.go +++ b/src/feeds/db_test.go @@ -56,7 +56,7 @@ func TestFeeds(t *testing.T) { t.Error("execution.version") } - if err := feeds.Executed(ctx, got.Entry.ID, got.Version.Created); err != nil { + if err := got.Executed(ctx); err != nil { t.Fatal("cannot executed:", err) } @@ -78,7 +78,7 @@ func TestFeeds(t *testing.T) { t.Errorf("changes after execution: was \n\t%+v but now \n\t%+v", got, got2) } - if err := feeds.Executed(ctx, got.Entry.ID, got.Version.Created); err != nil { + if err := got.Executed(ctx); err != nil { t.Fatal("cannot executed again:", err) } got3, err := feeds.Get(ctx, id) diff --git a/src/feeds/http.go b/src/feeds/http.go new file mode 100644 index 0000000..bd564a3 --- /dev/null +++ b/src/feeds/http.go @@ -0,0 +1,10 @@ +package feeds + +import ( + "context" + "io" +) + +func (feed Feed) Fetch(ctx context.Context) (Items, error) { + return nil, io.EOF +} diff --git a/src/feeds/http_test.go b/src/feeds/http_test.go new file mode 100644 index 0000000..3497b2e --- /dev/null +++ b/src/feeds/http_test.go @@ -0,0 +1 @@ +package feeds_test diff --git a/src/feeds/item.go b/src/feeds/item.go new file mode 100644 index 0000000..062ca5f --- /dev/null +++ b/src/feeds/item.go @@ -0,0 +1,5 @@ +package feeds + +type Items []Item + +type Item struct{}