package cron_test import ( "context" "database/sql" "testing" "git.jamestombleson.com/jtom38/newsbot-api/internal/services/cron" _ "github.com/glebarez/go-sqlite" "github.com/pressly/goose/v3" ) func TestCheckReddit(t *testing.T) { db, err := setupInMemoryDb() if err != nil { t.Log(err) t.FailNow() } defer db.Close() ctx := context.Background() c := cron.NewScheduler(ctx, db) c.CheckReddit() } func TestCheckYouTube(t *testing.T) { db, err := setupInMemoryDb() if err != nil { t.Log(err) t.FailNow() } defer db.Close() ctx := context.Background() c := cron.NewScheduler(ctx, db) c.CheckYoutube() } func TestCheckTwitch(t *testing.T) { db, err := setupInMemoryDb() if err != nil { t.Log(err) t.FailNow() } defer db.Close() ctx := context.Background() c := cron.NewScheduler(ctx, db) err = c.CheckTwitch() if err != nil { t.Error(err) } } func setupInMemoryDb() (*sql.DB, error) { db, err := sql.Open("sqlite", ":memory:") if err != nil { return nil, err } err = goose.SetDialect("sqlite3") if err != nil { return nil, err } err = goose.Up(db, "../database/migrations") if err != nil { return nil, err } return db, nil }