本文整理汇总了Golang中github.com/viki-org/gspec.New函数的典型用法代码示例。如果您正苦于以下问题:Golang New函数的具体用法?Golang New怎么用?Golang New使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了New函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestSetsTheBodyPoolSize
func TestSetsTheBodyPoolSize(t *testing.T) {
spec := gspec.New(t)
c := Configure().BodyPool(10, 16)
//allocate 1 extra byte so we know if the body is too large (or just right)
spec.Expect(c.maxBodySize).ToEqual(int64(17))
spec.Expect(c.bodyPoolSize).ToEqual(10)
}
示例2: TestInvalidWhenStringLengthIsOutsideLen
func TestInvalidWhenStringLengthIsOutsideLen(t *testing.T) {
spec := gspec.New(t)
rule := Len(4, 6)
for _, str := range []string{"123", "12", "1234567", "12345678"} {
spec.Expect(rule.Verify(str)).ToEqual(false)
}
}
示例3: TestSetsTheNotFoundResponse
func TestSetsTheNotFoundResponse(t *testing.T) {
spec := gspec.New(t)
expected := Json("the res").Status(244).Response
actual := Configure().NotFoundResponse(expected).notFound
spec.Expect(actual.GetStatus()).ToEqual(244)
spec.Expect(string(actual.GetBody())).ToEqual("the res")
}
示例4: TestMultipleRanges
func TestMultipleRanges(t *testing.T) {
spec := gspec.New(t)
ranges := ParseRange("bytes=7-8,17-100")
spec.Expect(len(ranges)).ToEqual(2)
spec.Expect(ranges[0]).ToEqual(*&Range{7, 8})
spec.Expect(ranges[1]).ToEqual(*&Range{17, 100})
}
示例5: TestInvalidWhenStringIsTooShort
func TestInvalidWhenStringIsTooShort(t *testing.T) {
spec := gspec.New(t)
rule := MinLen(4)
for _, str := range []string{"1", "12", "123"} {
spec.Expect(rule.Verify(str)).ToEqual(false)
}
}
示例6: TestCreatesARequestWithTheCorrectRange
func TestCreatesARequestWithTheCorrectRange(t *testing.T) {
spec := gspec.New(t)
context := core.NewContext(gspec.Request().Url("somefile.mp4").Req)
context.Chunk = 3
req := newRequest(context, &core.Config{RangedExtensions: map[string]bool{".mp4": true}})
spec.Expect(req.Header.Get("range")).ToEqual("bytes=6291456-8388607")
}
示例7: TestGetReturnsTheItemWithEmptySecondaryKey
func TestGetReturnsTheItemWithEmptySecondaryKey(t *testing.T) {
spec := gspec.New(t)
c := New(Configure())
item := NewItem("SAMPLE BODY FOR TESTING")
c.Set("the-p", "", item)
spec.Expect(c.Get("the-p", "")).ToEqual(item)
}
示例8: TestValidWhenStringIsShorterThanMaxLen
func TestValidWhenStringIsShorterThanMaxLen(t *testing.T) {
spec := gspec.New(t)
rule := MaxLen(4)
for _, str := range []string{"1", "12", "123", "1234"} {
spec.Expect(rule.Verify(str)).ToEqual(true)
}
}
示例9: TestIgnoresTheRangeForNonRangeTypes
func TestIgnoresTheRangeForNonRangeTypes(t *testing.T) {
spec := gspec.New(t)
context := core.NewContext(gspec.Request().Url("somefile.mp4").Req)
context.Chunk = 3
req := newRequest(context, new(core.Config))
spec.Expect(req.Header.Get("range")).ToEqual("")
}
示例10: TestLoadsAConfiguration
func TestLoadsAConfiguration(t *testing.T) {
spec := gspec.New(t)
loadConfig([]byte(`{"listen":"1.123.58.13:9001", "upstream":"its.over.net"}`))
config := GetConfig()
spec.Expect(config.Listen).ToEqual("1.123.58.13:9001")
spec.Expect(config.Upstream).ToEqual("its.over.net")
}
示例11: TestCreatesARequestWithTheCorrectHostAndUrl
func TestCreatesARequestWithTheCorrectHostAndUrl(t *testing.T) {
spec := gspec.New(t)
context := core.NewContext(gspec.Request().Url("/test.json").Req)
req := newRequest(context, &core.Config{Upstream: "s3.viki.com"})
spec.Expect(req.Host).ToEqual("s3.viki.com")
spec.Expect(req.URL.Path).ToEqual("/test.json")
}
示例12: TestValidWhenStringIsLongerThanMinLen
func TestValidWhenStringIsLongerThanMinLen(t *testing.T) {
spec := gspec.New(t)
rule := MinLen(4)
for _, str := range []string{"1234", "12345", "123456"} {
spec.Expect(rule.Verify(str)).ToEqual(true)
}
}
示例13: TestInvalidWhenStringIsTooLong
func TestInvalidWhenStringIsTooLong(t *testing.T) {
spec := gspec.New(t)
rule := MaxLen(4)
for _, str := range []string{"12345", "123456"} {
spec.Expect(rule.Verify(str)).ToEqual(false)
}
}
示例14: TestValidWhenStringLengthIsWithinLen
func TestValidWhenStringLengthIsWithinLen(t *testing.T) {
spec := gspec.New(t)
rule := Len(4, 6)
for _, str := range []string{"1234", "12345", "123456"} {
spec.Expect(rule.Verify(str)).ToEqual(true)
}
}
示例15: TestAddingMultipleSimpleRoutes
func TestAddingMultipleSimpleRoutes(t *testing.T) {
spec := gspec.New(t)
c := Configure().
Route(R("GET", "v1", "gholas", "getgholas")).
Route(R("LIST", "v1", "gholas", "listgholas"))
spec.Expect(c.routes["v1"]["gholas"]["GET"].Action.(string)).ToEqual("getgholas")
spec.Expect(c.routes["v1"]["gholas"]["LIST"].Action.(string)).ToEqual("listgholas")
}