-
Notifications
You must be signed in to change notification settings - Fork 0
/
grab_test.go
46 lines (37 loc) · 1022 Bytes
/
grab_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package main
import (
"os"
"path/filepath"
"testing"
"github.com/stretchr/testify/require"
"go.bbkane.com/warg"
)
func TestGrabE2E(t *testing.T) {
// A non-deterministic test,so we do have to inspect the output...
// But it's the best way to determine if reddit really works too
run := os.Getenv("GRABBIT_TEST_RUN_E2E") != ""
if !run {
t.Skip("Skipping Test. Run with\n GRABBIT_TEST_RUN_E2E=1 go test ./...")
}
dir, err := os.MkdirTemp("", "grabbit-grab-e2e")
require.Nil(t, err)
t.Logf("Using tmpdir: %s", dir)
app := app()
args := []string{
"grabbit", "grab",
"--subreddit-destination", dir,
"--subreddit-limit", "1",
"--subreddit-name", "wallpapers",
"--subreddit-timeframe", "day",
// hack to not use a config
"--config", "not-there",
"--log-filename", filepath.Join(dir, "log.jsonl"),
}
parsed, err := app.Parse(
warg.OverrideArgs(args),
warg.OverrideLookupFunc(warg.LookupMap(nil)),
)
require.Nil(t, err)
err = parsed.Action(parsed.Context)
require.Nil(t, err)
}