Repository navigation
Expand file tree
/
Copy pathbatch_test.go
More file actions
139 lines (129 loc) · 3.74 KB
/
Copy pathbatch_test.go
File metadata and controls
139 lines (129 loc) · 3.74 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
package cmd
import (
"testing"
"github.com/context-dot-dev/context-dev-cli/internal/mocktest"
)
func TestBatchRetrieve(t *testing.T) {
t.Skip("Mock server tests are disabled")
t.Run("regular flags", func(t *testing.T) {
mocktest.TestRunMockTestWithFlags(
t,
"--api-key", "string",
"batch", "retrieve",
"--batch-id", "batch_9f2c8a",
)
})
}
func TestBatchList(t *testing.T) {
t.Skip("Mock server tests are disabled")
t.Run("regular flags", func(t *testing.T) {
mocktest.TestRunMockTestWithFlags(
t,
"--api-key", "string",
"batch", "list",
"--cursor", "cursor",
"--limit", "1",
"--q", "batch_1a2b",
"--search-type", "exact",
"--status", "queued",
"--tags", "docs,competitor",
)
})
}
func TestBatchDelete(t *testing.T) {
t.Skip("Mock server tests are disabled")
t.Run("regular flags", func(t *testing.T) {
mocktest.TestRunMockTestWithFlags(
t,
"--api-key", "string",
"batch", "delete",
"--batch-id", "batch_9f2c8a",
)
})
}
func TestBatchCancel(t *testing.T) {
t.Skip("Mock server tests are disabled")
t.Run("regular flags", func(t *testing.T) {
mocktest.TestRunMockTestWithFlags(
t,
"--api-key", "string",
"batch", "cancel",
"--batch-id", "batch_9f2c8a",
)
})
}
func TestBatchGetResults(t *testing.T) {
t.Skip("Mock server tests are disabled")
t.Run("regular flags", func(t *testing.T) {
mocktest.TestRunMockTestWithFlags(
t,
"--api-key", "string",
"batch", "get-results",
"--batch-id", "batch_9f2c8a",
"--cursor", "cursor",
"--limit", "1",
)
})
}
func TestBatchSubmit(t *testing.T) {
t.Skip("Mock server tests are disabled")
t.Run("regular flags", func(t *testing.T) {
mocktest.TestRunMockTestWithFlags(
t,
"--api-key", "string",
"batch", "submit",
"--input", "{data: {format: markdown, urls: [{url: https://example.com/products/anvil, itemId: sku-1, meta: {category: bar}}, {url: https://example.com/products/hammer, itemId: sku-2, meta: {foo: bar}}], options: {country: de, excludeSelectors: [x], includeHTML: true, includeImages: true, includeLinks: true, includeSelectors: [x], maxAgeMs: 0, pdf: {end: 1, ocr: true, shouldParse: true, start: 1}, settleAnimations: true, shortenBase64Images: true, useMainContentOnly: true, waitForMs: 0}}, mode: scrape}",
"--tag", "docs",
"--tag", "competitor",
"--webhook-url", "webhookUrl",
"--idempotency-key", "Idempotency-Key",
)
})
t.Run("piping data", func(t *testing.T) {
// Test piping YAML data over stdin
pipeData := []byte("" +
"input:\n" +
" data:\n" +
" format: markdown\n" +
" urls:\n" +
" - url: https://example.com/products/anvil\n" +
" itemId: sku-1\n" +
" meta:\n" +
" category: bar\n" +
" - url: https://example.com/products/hammer\n" +
" itemId: sku-2\n" +
" meta:\n" +
" foo: bar\n" +
" options:\n" +
" country: de\n" +
" excludeSelectors:\n" +
" - x\n" +
" includeHTML: true\n" +
" includeImages: true\n" +
" includeLinks: true\n" +
" includeSelectors:\n" +
" - x\n" +
" maxAgeMs: 0\n" +
" pdf:\n" +
" end: 1\n" +
" ocr: true\n" +
" shouldParse: true\n" +
" start: 1\n" +
" settleAnimations: true\n" +
" shortenBase64Images: true\n" +
" useMainContentOnly: true\n" +
" waitForMs: 0\n" +
" mode: scrape\n" +
"tags:\n" +
" - docs\n" +
" - competitor\n" +
"webhookUrl: webhookUrl\n")
mocktest.TestRunMockTestWithPipeAndFlags(
t, pipeData,
"--api-key", "string",
"batch", "submit",
"--idempotency-key", "Idempotency-Key",
)
})
}