本文整理汇总了Golang中github.com/alecthomas/assert.True函数的典型用法代码示例。如果您正苦于以下问题:Golang True函数的具体用法?Golang True怎么用?Golang True使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了True函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestLinkedSubscriptionUnsubscribesTargetOnLink
func TestLinkedSubscriptionUnsubscribesTargetOnLink(t *testing.T) {
linked := NewLinkedSubscription()
sub := NewGenericSubscription()
linked.Dispose()
assert.True(t, linked.Disposed())
assert.False(t, sub.Disposed())
linked.Link(sub)
assert.True(t, linked.Disposed())
assert.True(t, sub.Disposed())
}
示例2: TestLinkedSubscription
func TestLinkedSubscription(t *testing.T) {
linked := NewLinkedSubscription()
sub := NewGenericSubscription()
assert.False(t, linked.Disposed())
assert.False(t, sub.Disposed())
linked.Link(sub)
assert.Panics(t, func() { linked.Link(sub) })
linked.Dispose()
assert.True(t, sub.Disposed())
assert.True(t, linked.Disposed())
}
示例3: TestCombinedShortFlags
func TestCombinedShortFlags(t *testing.T) {
app := newTestApp()
a := app.Flag("short0", "").Short('0').Bool()
b := app.Flag("short1", "").Short('1').Bool()
c := app.Flag("short2", "").Short('2').Bool()
_, err := app.Parse([]string{"-01"})
assert.NoError(t, err)
assert.True(t, *a)
assert.True(t, *b)
assert.False(t, *c)
}
示例4: TestChannelSubscription
func TestChannelSubscription(t *testing.T) {
done := make(chan bool)
unsubscribed := false
var s Subscription = NewChannelSubscription()
events, ok := s.(SubscriptionEvents)
assert.True(t, ok)
events.OnUnsubscribe(func() { unsubscribed = true; done <- true })
assert.False(t, s.Disposed())
s.Dispose()
assert.True(t, s.Disposed())
<-done
assert.True(t, unsubscribed)
}
示例5: TestDoOnComplete
func TestDoOnComplete(t *testing.T) {
complete := false
a, err := EmptyInt().DoOnComplete(func() { complete = true }).ToArrayWithError()
assert.NoError(t, err)
assert.Equal(t, []int{}, a)
assert.True(t, complete)
}
示例6: TestBool
func TestBool(t *testing.T) {
app := newTestApp()
b := app.Flag("b", "").Bool()
_, err := app.Parse([]string{"--b"})
assert.NoError(t, err)
assert.True(t, *b)
}
示例7: TestShortFlag
func TestShortFlag(t *testing.T) {
app := newTestApp()
f := app.Flag("long", "").Short('s').Bool()
_, err := app.Parse([]string{"-s"})
assert.NoError(t, err)
assert.True(t, *f)
}
示例8: TestNestedCommandWithMergedFlags
func TestNestedCommandWithMergedFlags(t *testing.T) {
app := New("app", "")
cmd0 := app.Command("a", "")
cmd0f0 := cmd0.Flag("aflag", "").Bool()
// cmd1 := app.Command("b", "")
// cmd1f0 := cmd0.Flag("bflag", "").Bool()
cmd00 := cmd0.Command("aa", "")
cmd00f0 := cmd00.Flag("aaflag", "").Bool()
err := app.init()
assert.NoError(t, err)
context := tokenize(strings.Split("a aa --aflag --aaflag", " "), false)
selected, err := parseAndExecute(app, context)
assert.NoError(t, err)
assert.True(t, *cmd0f0)
assert.True(t, *cmd00f0)
assert.Equal(t, "a aa", selected)
}
示例9: Test_Renewal
func Test_Renewal(t *testing.T) {
res := &http.Response{
StatusCode: 400,
}
assert.True(t, needsRenewal(res, nil))
res.StatusCode = 200
assert.False(t, needsRenewal(res, nil))
}
示例10: TestTimeout
func TestTimeout(t *testing.T) {
wg := sync.WaitGroup{}
start := time.Now()
wg.Add(1)
actual, err := CreateInt(func(observer IntObserver, subscription Subscription) {
observer.Next(1)
time.Sleep(time.Millisecond * 500)
assert.True(t, subscription.Disposed())
wg.Done()
}).
Timeout(time.Millisecond * 250).
ToArrayWithError()
elapsed := time.Now().Sub(start)
assert.Error(t, err)
assert.Equal(t, ErrTimeout, err)
assert.True(t, elapsed > time.Millisecond*250 && elapsed < time.Millisecond*500)
assert.Equal(t, []int{1}, actual)
wg.Wait()
}
示例11: TestDispatchCallbackIsCalled
func TestDispatchCallbackIsCalled(t *testing.T) {
dispatched := false
c := newTestApp()
c.Command("cmd", "").Action(func(*ParseContext) error {
dispatched = true
return nil
})
_, err := c.Parse([]string{"cmd"})
assert.NoError(t, err)
assert.True(t, dispatched)
}
示例12: Test_NewHealer
func Test_NewHealer(t *testing.T) {
_, err := NewHealer("", "/dev/null")
assert.Error(t, err)
_, err = NewHealer("nope,/dev/null", "invalid")
assert.Error(t, err)
healer, err := NewHealer("archive,/dev/null", "invalid")
assert.NoError(t, err)
_, ok := healer.(*ArchiveHealer)
assert.True(t, ok)
}
示例13: TestNestedCommandsWithArgs
func TestNestedCommandsWithArgs(t *testing.T) {
app := New("app", "")
cmd := app.Command("a", "").Command("b", "")
a := cmd.Arg("a", "").String()
b := cmd.Arg("b", "").String()
context := tokenize([]string{"a", "b", "c", "d"}, false)
selected, err := parseAndExecute(app, context)
assert.NoError(t, err)
assert.True(t, context.EOL())
assert.Equal(t, "a b", selected)
assert.Equal(t, "c", *a)
assert.Equal(t, "d", *b)
}
示例14: Test_FanOut
func Test_FanOut(t *testing.T) {
t.Logf("Testing fail fast...")
ts := &TestSink{
FailingBlock: BlockLocation{
FileIndex: 2,
BlockIndex: 2,
},
}
fos, err := NewFanOutSink(ts, 8)
assert.NoError(t, err)
fos.Start()
hadError := false
for i := 0; i < 8; i++ {
for j := 0; j < 8; j++ {
loc := BlockLocation{
FileIndex: int64(i),
BlockIndex: int64(j),
}
sErr := fos.Store(loc, []byte{})
if sErr != nil {
hadError = true
}
}
}
assert.True(t, hadError)
err = fos.Close()
assert.NoError(t, err)
t.Logf("Testing tail errors...")
fos, err = NewFanOutSink(ts, 8)
assert.NoError(t, err)
fos.Start()
// Store shouldn't err, just queue it...
err = fos.Store(ts.FailingBlock, []byte{})
assert.NoError(t, err)
// but close should catch the error
err = fos.Close()
assert.NotNil(t, err)
}
示例15: TestNestedCommandsWithFlags
func TestNestedCommandsWithFlags(t *testing.T) {
app := New("app", "")
cmd := app.Command("a", "").Command("b", "")
a := cmd.Flag("aaa", "").Short('a').String()
b := cmd.Flag("bbb", "").Short('b').String()
err := app.init()
assert.NoError(t, err)
context := tokenize(strings.Split("a b --aaa x -b x", " "), false)
selected, err := parseAndExecute(app, context)
assert.NoError(t, err)
assert.True(t, context.EOL())
assert.Equal(t, "a b", selected)
assert.Equal(t, "x", *a)
assert.Equal(t, "x", *b)
}