-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_multipleurlsoncmdline_test.go
42 lines (35 loc) · 1.38 KB
/
test_multipleurlsoncmdline_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
package main
import (
"testing"
curl "github.com/cdwiegand/go-curling/context"
curltestharness "github.com/cdwiegand/go-curling/tests"
"github.com/stretchr/testify/assert"
)
func Test_MultipleUrls_Context(t *testing.T) {
testRun := curltestharness.BuildTestRun(t)
testRun.ContextBuilder = func(testrun *curltestharness.TestRun) *curl.CurlContext {
testrun.GetOneOutputFile()
testrun.GetOneOutputFile()
return &curl.CurlContext{
Urls: []string{"https://httpbin.org/get?test=one", "https://httpbin.org/get?test=two"},
BodyOutput: testrun.EnsureAtLeastOneOutputFiles(),
}
}
testRun.SuccessHandlerIndexed = helper_MultipleUrls_success
testRun.RunTestRun()
}
func Test_MultipleUrls_CmdLine(t *testing.T) {
testRun := curltestharness.BuildTestRun(t)
testRun.CmdLineBuilder = func(testrun *curltestharness.TestRun) []string {
return []string{"https://httpbin.org/get?test=one", "https://httpbin.org/get?test=two", "-o", testrun.GetOneOutputFile(), "-o", testrun.GetOneOutputFile()}
}
testRun.SuccessHandlerIndexed = helper_MultipleUrls_success
testRun.RunTestRun()
}
func helper_MultipleUrls_success(json map[string]interface{}, index int, testrun *curltestharness.TestRun) {
t := testrun.Testing
expectedResult := []string{"one", "two"}
assert.NotNil(t, json["args"])
args := json["args"].(map[string]any)
assert.EqualValues(t, expectedResult[index], args["test"])
}