本文整理汇总了Golang中github.com/viki-org/gspec.New函数的典型用法代码示例。如果您正苦于以下问题:Golang New函数的具体用法?Golang New怎么用?Golang New使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了New函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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)
}
开发者ID:viki-org,项目名称:auwfg,代码行数:7,代码来源:configuration_test.go
示例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)
}
}
开发者ID:viki-org,项目名称:auwfg,代码行数:7,代码来源:len_test.go
示例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")
}
开发者ID:viki-org,项目名称:auwfg,代码行数:7,代码来源:configuration_test.go
示例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})
}
开发者ID:karlseguin,项目名称:seedcdn,代码行数:7,代码来源:range_test.go
示例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)
}
}
开发者ID:viki-org,项目名称:auwfg,代码行数:7,代码来源:minlen_test.go
示例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")
}
开发者ID:karlseguin,项目名称:seedcdn,代码行数:7,代码来源:proxy_test.go
示例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)
}
开发者ID:viki-org,项目名称:lrucache,代码行数:7,代码来源:lrucache_test.go
示例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)
}
}
开发者ID:viki-org,项目名称:auwfg,代码行数:7,代码来源:maxlen_test.go
示例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("")
}
开发者ID:karlseguin,项目名称:seedcdn,代码行数:7,代码来源:proxy_test.go
示例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")
}
开发者ID:karlseguin,项目名称:seedcdn,代码行数:7,代码来源:config_test.go
示例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")
}
开发者ID:karlseguin,项目名称:seedcdn,代码行数:7,代码来源:proxy_test.go
示例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)
}
}
开发者ID:viki-org,项目名称:auwfg,代码行数:7,代码来源:minlen_test.go
示例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)
}
}
开发者ID:viki-org,项目名称:auwfg,代码行数:7,代码来源:maxlen_test.go
示例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)
}
}
开发者ID:viki-org,项目名称:auwfg,代码行数:7,代码来源:len_test.go
示例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")
}
开发者ID:viki-org,项目名称:auwfg,代码行数:8,代码来源:configuration_test.go
示例16: TestComplexRange
func TestComplexRange(t *testing.T) {
spec := gspec.New(t)
ranges := ParseRange("bytes=1-10,25-100,-10")
spec.Expect(len(ranges)).ToEqual(3)
spec.Expect(ranges[0]).ToEqual(*&Range{1, 10})
spec.Expect(ranges[1]).ToEqual(*&Range{25, 100})
spec.Expect(ranges[2]).ToEqual(*&Range{0, -10})
}
开发者ID:karlseguin,项目名称:seedcdn,代码行数:8,代码来源:range_test.go
示例17: TestLogsStatisticsToRedis
func TestLogsStatisticsToRedis(t *testing.T) {
conn := pool.Get()
defer cleanup(conn)
spec := gspec.New(t)
Run(core.NewContext(gspec.Request().Url("/something/funny.txt").Req), nil, core.NoopMiddleware)
time.Sleep(time.Second * 1)
spec.Expect(redis.Int(conn.Do("zscore", "hits", "/something/funny.txt"))).ToEqual(1)
}
开发者ID:karlseguin,项目名称:seedcdn,代码行数:8,代码来源:logs_test.go
示例18: TestPrunesTheList1
func TestPrunesTheList1(t *testing.T) {
spec := gspec.New(t)
l, one, two, three := sampleList()
items := l.Prune(1)
assertList(t, l, one, two)
spec.Expect(items[0]).ToEqual(three)
spec.Expect(len(items)).ToEqual(1)
}
开发者ID:viki-org,项目名称:lrucache,代码行数:8,代码来源:list_test.go
示例19: TestNoIpPresent
func TestNoIpPresent(t *testing.T) {
f := func(context *TestContext) Response {
gspec.New(t).Expect(context.Ip).ToEqual("127.0.0.1")
return Json("").Response
}
c := Configure().Route(R("GET", "v1", "worms", f)).ContextFactory(testContextFactory).Dispatcher(testDispatcher)
req := gspec.Request().Url("/v1/worms/22w.json").Method("GET").Req
newRouter(c).ServeHTTP(httptest.NewRecorder(), req)
}
开发者ID:viki-org,项目名称:auwfg,代码行数:9,代码来源:context_test.go
示例20: TestSetsANewBucketItem
func TestSetsANewBucketItem(t *testing.T) {
spec := gspec.New(t)
bucket := testBucket()
item, new := bucket.set("spice", TestValue("flow"), time.Minute)
assertValue(t, item, "flow")
item = bucket.get("spice")
assertValue(t, item, "flow")
spec.Expect(new).ToEqual(true)
}
开发者ID:viki-org,项目名称:ccache,代码行数:9,代码来源:bucket_test.go
注:本文中的github.com/viki-org/gspec.New函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论