本文整理汇总了Golang中github.com/matryer/silk/runner.New函数的典型用法代码示例。如果您正苦于以下问题:Golang New函数的具体用法?Golang New怎么用?Golang New使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了New函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestIssue31
// https://github.com/matryer/silk/issues/31
func TestIssue31(t *testing.T) {
is := is.New(t)
subT := &testT{}
s := httptest.NewServer(testutil.EchoHandler())
defer s.Close()
r := runner.New(subT, s.URL)
r.RunFile("../testfiles/success/issue-31.silk.md")
is.False(subT.Failed())
}
示例2: TestRunFileSuccessNoBody
func TestRunFileSuccessNoBody(t *testing.T) {
is := is.New(t)
subT := &testT{}
s := httptest.NewServer(testutil.EchoHandler())
defer s.Close()
r := runner.New(subT, s.URL)
r.RunFile("../testfiles/success/echo.nobody.success.silk.md")
is.False(subT.Failed())
}
示例3: TestBodyField
func TestBodyField(t *testing.T) {
is := is.New(t)
subT := &testT{}
s := httptest.NewServer(testutil.EchoDataHandler())
defer s.Close()
r := runner.New(subT, s.URL)
r.RunFile("../testfiles/success/body-as-field.silk.md")
is.False(subT.Failed())
}
示例4: testFunc
func testFunc(t *testing.T) {
r := runner.New(t, *url)
files, err := filepath.Glob(root)
if err != nil {
log.Fatalln(err)
}
fmt.Println("running", len(files), "file(s)")
r.RunGlob(files, nil)
}
示例5: TestStandardSeparator
// https://github.com/matryer/silk/issues/37
func TestStandardSeparator(t *testing.T) {
is := is.New(t)
subT := &testT{}
s := httptest.NewServer(testutil.EchoHandler())
defer s.Close()
os.Setenv("$AppNameFromEnv", "Silk")
r := runner.New(subT, s.URL)
r.RunFile("../testfiles/success/issue-37.silk.md")
is.False(subT.Failed())
}
示例6: TestGlob
func TestGlob(t *testing.T) {
is := is.New(t)
subT := &testT{}
s := httptest.NewServer(testutil.EchoHandler())
defer s.Close()
r := runner.New(subT, s.URL)
r.Log = func(s string) {} // don't bother logging
r.RunGlob(filepath.Glob("../testfiles/failure/echo.*.silk.md"))
is.True(subT.Failed())
}
示例7: TestHello
func TestHello(t *testing.T) {
// start test server
server := httptest.NewServer(example.NewServer())
defer server.Close()
// make a new runner using the server URL as the target
// and run the test file.
runner.New(t, server.URL).RunFile("hello.silk.md")
}
示例8: TestCapturedVars
// https://github.com/matryer/silk/issues/2
func TestCapturedVars(t *testing.T) {
is := is.New(t)
subT := &testT{}
s := httptest.NewServer(testutil.EchoDataHandler())
defer s.Close()
os.Setenv("$EnvStatus", "awesome")
os.Setenv("$AppNameFromEnv", "Silk")
r := runner.New(subT, s.URL)
r.RunFile("../testfiles/success/captured-vars.silk.md")
is.False(subT.Failed())
}
示例9: TestRunJsonModesFailure
func TestRunJsonModesFailure(t *testing.T) {
is := is.New(t)
subT := &testT{}
s := httptest.NewServer(testutil.EchoRawHandler())
defer s.Close()
r := runner.New(subT, s.URL)
g, err := parse.ParseFile("../testfiles/failure/echoraw.failure.jsonmodes.silk.md")
is.NoErr(err)
r.RunGroup(g...)
is.True(subT.Failed())
}
示例10: TestRunGroupSuccess
func TestRunGroupSuccess(t *testing.T) {
is := is.New(t)
subT := &testT{}
s := httptest.NewServer(testutil.EchoHandler())
defer s.Close()
r := runner.New(subT, s.URL)
g, err := parse.ParseFile("../testfiles/success/echo.success.silk.md")
is.NoErr(err)
r.RunGroup(g...)
is.False(subT.Failed())
}
示例11: TestFailureFieldsDifferentTypes
func TestFailureFieldsDifferentTypes(t *testing.T) {
is := is.New(t)
subT := &testT{}
s := httptest.NewServer(testutil.EchoHandler())
defer s.Close()
r := runner.New(subT, s.URL)
var logs []string
r.Log = func(s string) {
logs = append(logs, s)
}
g, err := parse.ParseFile("../testfiles/failure/echo.failure.fieldsdifferenttypes.silk.md")
is.NoErr(err)
r.RunGroup(g...)
is.True(subT.Failed())
logstr := strings.Join(logs, "\n")
is.True(strings.Contains(logstr, `Status expected string: "400" actual float64: 200`))
}
示例12: TestFailureWrongHeader
func TestFailureWrongHeader(t *testing.T) {
is := is.New(t)
subT := &testT{}
s := httptest.NewServer(testutil.EchoHandler())
defer s.Close()
r := runner.New(subT, s.URL)
var logs []string
r.Log = func(s string) {
logs = append(logs, s)
}
g, err := parse.ParseFile("../testfiles/failure/echo.failure.wrongheader.silk.md")
is.NoErr(err)
r.RunGroup(g...)
is.True(subT.Failed())
logstr := strings.Join(logs, "\n")
is.True(strings.Contains(logstr, `Content-Type expected string: "wrong/type" actual string: "text/plain; charset=utf-8"`))
is.True(strings.Contains(logstr, "--- FAIL: GET /echo"))
is.True(strings.Contains(logstr, "../testfiles/failure/echo.failure.wrongheader.silk.md:22 - Content-Type doesn't match"))
}
示例13: TestFailureNonTrimmedExpection
// https://github.com/matryer/silk/issues/28
func TestFailureNonTrimmedExpection(t *testing.T) {
is := is.New(t)
subT := &testT{}
s := httptest.NewServer(testutil.EchoDataHandler())
defer s.Close()
r := runner.New(subT, s.URL)
var logs []string
r.Log = func(s string) {
logs = append(logs, s)
}
g, err := parse.ParseFile("../testfiles/failure/echo.failure.nontrimmedexpectation.silk.md")
is.NoErr(err)
r.RunGroup(g...)
is.True(subT.Failed())
logstr := strings.Join(logs, "\n")
is.True(strings.Contains(logstr, `Data.body.status expected: "awesome" actual: " awesome"`))
is.True(strings.Contains(logstr, "--- FAIL: GET /echo"))
is.True(strings.Contains(logstr, "../testfiles/failure/echo.failure.nontrimmedexpectation.silk.md:18 - Data.body.status doesn't match"))
}
示例14: TestFailureWrongBody
func TestFailureWrongBody(t *testing.T) {
is := is.New(t)
subT := &testT{}
s := httptest.NewServer(testutil.EchoHandler())
defer s.Close()
r := runner.New(subT, s.URL)
var logs []string
r.Log = func(s string) {
logs = append(logs, s)
}
g, err := parse.ParseFile("../testfiles/failure/echo.failure.wrongbody.silk.md")
is.NoErr(err)
r.RunGroup(g...)
is.True(subT.Failed())
logstr := strings.Join(logs, "\n")
is.True(strings.Contains(logstr, "body expected:"))
is.True(strings.Contains(logstr, "GET /echo"))
is.True(strings.Contains(logstr, "Hello silky."))
is.True(strings.Contains(logstr, "actual:"))
is.True(strings.Contains(logstr, "GET /echo"))
is.True(strings.Contains(logstr, "Hello silk."))
is.True(strings.Contains(logstr, "--- FAIL: GET /echo"))
is.True(strings.Contains(logstr, "../testfiles/failure/echo.failure.wrongbody.silk.md:14 - body doesn't match"))
}
示例15: testFunc
func testFunc(t *testing.T) {
r := runner.New(t, *url)
fmt.Println("silk: running", len(paths), "file(s)...")
r.RunGlob(paths, nil)
}