本文整理汇总了Golang中github.com/karlseguin/gspec.New函数的典型用法代码示例。如果您正苦于以下问题:Golang New函数的具体用法?Golang New怎么用?Golang New使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了New函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: 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)
}
}
示例2: 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)
}
}
示例3: TestParserReadsContainsCondition
func TestParserReadsContainsCondition(t *testing.T) {
spec := gspec.New(t)
parser := newParser(" 'xyz' contains true%}")
group, err := parser.ReadConditionGroup()
spec.Expect(err).ToBeNil()
assertParsedConditionGroup(t, group, "xyz", Contains, true)
}
示例4: 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")
}
示例5: TestReverseASingleElementArray
func TestReverseASingleElementArray(t *testing.T) {
spec := gspec.New(t)
filter := ReverseFactory(nil)
values := filter([]bool{true}, nil).([]bool)
spec.Expect(len(values)).ToEqual(1)
spec.Expect(values[0]).ToEqual(true)
}
示例6: TestSetContainsAnExistingIdIfMultipleIndexesContainsIt
func TestSetContainsAnExistingIdIfMultipleIndexesContainsIt(t *testing.T) {
spec := gspec.New(t)
union := NewUnion("x", []string{"apple", "orange"})
union.On(makeSetIndex(20, 23, 24, 25, 26))
union.On(makeSetIndex(20, 25, 28, 29))
spec.Expect(union.Contains(key.Type(20))).ToEqual(true)
}
示例7: 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)
}
}
示例8: TestMockIsLimitedToASingleInvocation
func TestMockIsLimitedToASingleInvocation(t *testing.T) {
spec := gspec.New(t)
fake := newFake()
fake.Expect(fake.GetEmail).Returning("first").Once()
spec.Expect(fake.GetEmail("leto")).ToEqual("first")
spec.Expect(fake.GetEmail("paul")).ToEqual("[email protected]")
}
示例9: TestMockReturnsTheValueOnceByDefaultTimes
func TestMockReturnsTheValueOnceByDefaultTimes(t *testing.T) {
spec := gspec.New(t)
fake := newFake()
fake.Expect(fake.GetEmail).Returning("invalid")
spec.Expect(fake.GetEmail("leto")).ToEqual("invalid")
spec.Expect(fake.GetEmail("paul")).ToEqual("[email protected]")
}
示例10: assertStaticValue
func assertStaticValue(t *testing.T, data string, expected interface{}) {
spec := gspec.New(t)
p := NewParser([]byte(data))
value, err := p.ReadValue()
spec.Expect(err).ToBeNil()
spec.Expect(value.Resolve(nil)).ToEqual(expected)
}
示例11: assertErrorValue
func assertErrorValue(t *testing.T, data string, expected string) {
spec := gspec.New(t)
p := NewParser([]byte(data))
value, err := p.ReadValue()
spec.Expect(err.Error()).ToEqual(expected)
spec.Expect(value).ToBeNil()
}
示例12: TestStubReturnsTheValueMultipleTimes
func TestStubReturnsTheValueMultipleTimes(t *testing.T) {
spec := gspec.New(t)
fake := newFake()
fake.Stub(fake.GetEmail).Returning("invalid")
spec.Expect(fake.GetEmail("leto")).ToEqual("invalid")
spec.Expect(fake.GetEmail("paul")).ToEqual("invalid")
}
示例13: TestQueryCapsTheLimit
func TestQueryCapsTheLimit(t *testing.T) {
spec := gspec.New(t)
db := SmallDB()
defer db.Close()
query := <-db.queryPool
spec.Expect(query.Limit(200).(*NormalQuery).limit).ToEqual(100)
}
示例14: TestEmptyQueryOnInvalidIndex
func TestEmptyQueryOnInvalidIndex(t *testing.T) {
spec := gspec.New(t)
db := SmallDB()
defer db.Close()
_, ok := db.Query("cats").(*EmptyQuery)
spec.Expect(ok).ToEqual(true)
}
示例15: TestParserReadsASinglePartial
func TestParserReadsASinglePartial(t *testing.T) {
spec := gspec.New(t)
parser := newParser(" true %}")
group, err := parser.ReadPartialCondition()
spec.Expect(err).ToBeNil()
assertParsedConditionGroup(t, group, true, UnknownComparator, nil)
}