本文整理汇总了Golang中github.com/stretchr/testify/assert.NotPanics函数的典型用法代码示例。如果您正苦于以下问题:Golang NotPanics函数的具体用法?Golang NotPanics怎么用?Golang NotPanics使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NotPanics函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: TestSendPings
func TestSendPings(t *testing.T) {
d := newDefaultDaemon()
defer shutdown(d)
c := gnetConnection(addr)
go d.Pool.Pool.ConnectionWriteLoop(c)
d.Pool.Pool.Pool[1] = c
assert.NotPanics(t, d.Pool.sendPings)
wait()
assert.Equal(t, len(d.Pool.Pool.SendResults), 1)
if len(d.Pool.Pool.SendResults) == 0 {
t.Fatal("SendResults empty, would block")
}
sr := <-d.Pool.Pool.SendResults
assert.Equal(t, sr.Connection, c)
assert.Nil(t, sr.Error)
_, ok := sr.Message.(*PingMessage)
assert.True(t, ok)
assert.False(t, c.LastSent.IsZero())
// No pings should be sent, since we just pinged
lastSent := c.LastSent
assert.NotPanics(t, d.Pool.sendPings)
wait()
assert.Equal(t, len(d.Pool.Pool.SendResults), 0)
assert.Equal(t, c.LastSent, lastSent)
}
开发者ID:kinghuabg,项目名称:skycoin,代码行数:26,代码来源:daemon_test.go
示例2: TestCacheExtractorRemoteServer
func TestCacheExtractorRemoteServer(t *testing.T) {
ts := httptest.NewServer(http.HandlerFunc(testServeCache))
defer ts.Close()
defer os.Remove(cacheExtractorArchive)
defer os.Remove(cacheExtractorTestArchivedFile)
os.Remove(cacheExtractorArchive)
os.Remove(cacheExtractorTestArchivedFile)
helpers.MakeFatalToPanic()
cmd := CacheExtractorCommand{
File: cacheExtractorArchive,
URL: ts.URL + "/cache.zip",
}
assert.NotPanics(t, func() {
cmd.Execute(nil)
})
_, err := os.Stat(cacheExtractorTestArchivedFile)
assert.NoError(t, err)
os.Chtimes(cacheExtractorArchive, time.Now().Add(time.Hour), time.Now().Add(time.Hour))
assert.NotPanics(t, func() {
cmd.Execute(nil)
}, "archive is up to date")
}
开发者ID:bssthu,项目名称:gitlab-ci-multi-runner,代码行数:26,代码来源:cache_extractor_test.go
示例3: TestMiddleware
// TestMiddleware runs
func TestMiddleware(t *testing.T) {
assert := assert.New(t)
mw := Middleware{}
mw.Func = func() {
}
assert.Panics(func() {
mw.HandlerFunc()
})
ProdModeClosure(func() {
assert.NotPanics(func() {
mw.HandlerFunc()
})
})
mw.Func = func(c *gin.Context) {
}
assert.IsType(*new(gin.HandlerFunc), mw.HandlerFunc())
mw.Func = func(c Context) {
}
assert.IsType(*new(gin.HandlerFunc), mw.HandlerFunc())
assert.NotPanics(func() {
mw.HandlerFunc()(nil)
})
mw = LoggerMiddleware()
assert.IsType(*new(gin.HandlerFunc), mw.HandlerFunc())
}
开发者ID:gophergala2016,项目名称:source,代码行数:32,代码来源:middleware_test.go
示例4: TestVisorShutdown
func TestVisorShutdown(t *testing.T) {
defer cleanupVisor()
c, _ := setupVisor()
c.Disabled = true
c.Config.BlockchainFile = testBlockchainFile
c.Config.BlockSigsFile = testBlocksigsFile
c.Config.WalletFile = testWalletFile
v := NewVisor(c)
assert.NotPanics(t, v.Shutdown)
// Should not save anything
assertFileNotExists(t, testBlockchainFile)
assertFileNotExists(t, testBlocksigsFile)
assertFileNotExists(t, testWalletFile)
cleanupVisor()
c.Disabled = false
v = NewVisor(c)
assert.NotPanics(t, v.Shutdown)
assertFileExists(t, testBlockchainFile)
assertFileExists(t, testBlocksigsFile)
assertFileExists(t, testWalletFile)
cleanupVisor()
// If master, no wallet should be saved
c = setupMasterVisor()
c.Config.BlockchainFile = testBlockchainFile
c.Config.BlockSigsFile = testBlocksigsFile
c.Config.WalletFile = testWalletFile
v = NewVisor(c)
assert.NotPanics(t, v.Shutdown)
assertFileExists(t, testBlockchainFile)
assertFileExists(t, testBlocksigsFile)
assertFileNotExists(t, testWalletFile)
cleanupVisor()
}
开发者ID:up4k,项目名称:skycoin,代码行数:35,代码来源:visor_test.go
示例5: TestConnectToRandomPeer
func TestConnectToRandomPeer(t *testing.T) {
d := newDefaultDaemon()
defer shutdown(d)
defer cleanupPeers()
// Disabled
d.Config.DisableOutgoingConnections = true
assert.NotPanics(t, d.connectToRandomPeer)
assert.Equal(t, len(d.pendingConnections), 0)
// Enabled, but only private peers
addr := "192.168.1.196:30954"
p, err := d.Peers.Peers.AddPeer(addr)
assert.Nil(t, err)
p.Private = true
d.Config.DisableOutgoingConnections = false
assert.NotPanics(t, d.connectToRandomPeer)
assert.Equal(t, len(d.pendingConnections), 0)
// Enabled, and we have a public peer
p.Private = false
assert.NotPanics(t, d.connectToRandomPeer)
assert.Equal(t, len(d.pendingConnections), 1)
assert.NotNil(t, d.pendingConnections[addr])
}
开发者ID:kinghuabg,项目名称:skycoin,代码行数:25,代码来源:daemon_test.go
示例6: TestAuthenticationSetUp
func TestAuthenticationSetUp(t *testing.T) {
assert.Panics(t, func() {
Authentication([]byte(""))
})
assert.NotPanics(t, func() {
Authentication(TEST_AUTH_KEY)
})
validTokenText, err := mockLoginToken("10", time.Now().Add(10*time.Second), TEST_AUTH_KEY)
assert.NoError(t, err)
handler := Authentication(TEST_AUTH_KEY)
// Run the handler with a valid token
c := createGinContext(validTokenText)
assert.NotPanics(t, func() {
handler(c)
})
assert.Empty(t, c.Errors)
assert.Equal(t, "10", c.MustGet(AuthUserIDKey))
assert.IsType(t, &jwt.Token{}, c.MustGet(AuthTokenKey))
// Run the handler with invalid token
// There is no easy way to create a gin writer to properly detect response
// Go will panic when Authentication tries to add error to an empty Writer object
// So we can assume that the validation failed and user is not allowed through :)
c = createGinContext("RANDOM TOKEN TEXT")
assert.Panics(t, func() {
handler(c)
})
}
开发者ID:nazwa,项目名称:Galaxy-Empires,代码行数:32,代码来源:authentication_test.go
示例7: TestVisorBroadcastBlock
func TestVisorBroadcastBlock(t *testing.T) {
defer cleanupVisor()
defer gnet.EraseMessages()
p, gc := setupPool()
vc, _ := setupVisor()
vc.Disabled = true
v := NewVisor(vc)
// Should not send anything if disabled
assert.NotPanics(t, func() {
v.broadcastBlock(visor.SignedBlock{}, p)
})
assert.Equal(t, len(p.Pool.SendResults), 0)
assert.True(t, gc.LastSent.IsZero())
// Sending
gc.Conn = NewDummyConn(addr)
vc.Disabled = false
v = NewVisor(vc)
sb := v.Visor.GetGenesisBlock()
assert.NotPanics(t, func() {
v.broadcastBlock(sb, p)
})
go p.Pool.ConnectionWriteLoop(gc)
wait()
assert.Equal(t, len(p.Pool.SendResults), 1)
if len(p.Pool.SendResults) == 0 {
t.Fatal("SendResults empty, would block")
}
sr := <-p.Pool.SendResults
assert.Equal(t, sr.Connection, gc)
_, ok := sr.Message.(*GiveBlocksMessage)
assert.True(t, ok)
assert.Nil(t, sr.Error)
assert.False(t, gc.LastSent.IsZero())
}
开发者ID:up4k,项目名称:skycoin,代码行数:35,代码来源:visor_test.go
示例8: TestVisorBroadcastTransaction
func TestVisorBroadcastTransaction(t *testing.T) {
defer cleanupVisor()
defer gnet.EraseMessages()
p, gc := setupPool()
go p.Pool.ConnectionWriteLoop(gc)
vc, _ := setupVisor()
vc.Disabled = true
v := NewVisor(vc)
ut := createUnconfirmedTxn()
assert.NotPanics(t, func() {
v.broadcastTransaction(ut.Txn, p)
})
wait()
assert.Equal(t, len(p.Pool.SendResults), 0)
assert.True(t, gc.LastSent.IsZero())
// Sending
vc.Disabled = false
gc.Conn = NewDummyConn(addr)
v = NewVisor(vc)
assert.NotPanics(t, func() {
v.broadcastTransaction(ut.Txn, p)
})
wait()
assert.Equal(t, len(p.Pool.SendResults), 1)
if len(p.Pool.SendResults) == 0 {
t.Fatal("SendResults empty, would block")
}
sr := <-p.Pool.SendResults
assert.Nil(t, sr.Error)
assert.Equal(t, sr.Connection, gc)
_, ok := sr.Message.(*GiveTxnsMessage)
assert.True(t, ok)
assert.False(t, gc.LastSent.IsZero())
}
开发者ID:up4k,项目名称:skycoin,代码行数:35,代码来源:visor_test.go
示例9: TestInitPeers
func TestInitPeers(t *testing.T) {
defer cleanupPeers()
c := NewPeersConfig()
peers := NewPeers(c)
// Write dummy peer db
fn := "./" + pex.PeerDatabaseFilename
cleanupPeers()
f, err := os.Create(fn)
assert.Nil(t, err)
if err != nil {
t.Fatalf("Error creating %s", fn)
}
_, err = f.Write([]byte(addr + " 0 0\n"))
assert.Nil(t, err)
f.Close()
peers.Config.DataDirectory = "./"
assert.NotPanics(t, func() { peers.Init() })
assert.Equal(t, len(peers.Peers.Peerlist), 1)
assert.NotNil(t, peers.Peers.Peerlist[addr])
assert.False(t, peers.Peers.AllowLocalhost)
peers.Config.AllowLocalhost = true
assert.NotPanics(t, func() { peers.Init() })
assert.True(t, peers.Peers.AllowLocalhost)
}
开发者ID:Chao-Jia,项目名称:skycoin,代码行数:27,代码来源:peers_test.go
示例10: TestVisorAnnounceBlocks
func TestVisorAnnounceBlocks(t *testing.T) {
defer cleanupVisor()
defer gnet.EraseMessages()
p, gc := setupPool()
vc, _ := setupVisor()
go p.Pool.ConnectionWriteLoop(gc)
// Disabled
vc.Disabled = true
v := NewVisor(vc)
assert.NotPanics(t, func() { v.AnnounceBlocks(p) })
wait()
assert.Equal(t, len(p.Pool.SendResults), 0)
assert.True(t, gc.LastSent.IsZero())
// Valid send
vc.Disabled = false
gc.Conn = NewDummyConn(addr)
v = NewVisor(vc)
assert.False(t, v.Config.Disabled)
assert.NotPanics(t, func() { v.AnnounceBlocks(p) })
wait()
assert.Equal(t, len(p.Pool.SendResults), 1)
if len(p.Pool.SendResults) == 0 {
t.Fatal("SendResults empty, would block")
}
sr := <-p.Pool.SendResults
assert.Nil(t, sr.Error)
assert.Equal(t, sr.Connection, gc)
_, ok := sr.Message.(*AnnounceBlocksMessage)
assert.True(t, ok)
assert.False(t, gc.LastSent.IsZero())
}
开发者ID:up4k,项目名称:skycoin,代码行数:33,代码来源:visor_test.go
示例11: TestOnDisconnect
func TestOnDisconnect(t *testing.T) {
gnet.EraseMessages()
d := newDefaultDaemon()
c := gnetConnection(addr)
var mirror uint32 = 100
// Not blacklistable
reason := gnet.DisconnectWriteFailed
setupTestOnDisconnect(d, c, mirror)
assert.NotPanics(t, func() { d.onGnetDisconnect(c, reason) })
// Should not be in blacklist
assert.Equal(t, len(d.Peers.Peers.Blacklist), 0)
// Should no longer be in OutgoingConnections
assert.Equal(t, len(d.OutgoingConnections), 0)
// Should no longer be in d.ExpectingIntroductions
assert.Equal(t, len(d.ExpectingIntroductions), 0)
// Should be removed from the mirror, and the mirror dict for this ip
// should be removed
assert.Equal(t, len(d.mirrorConnections), 0)
assert.Equal(t, len(d.ConnectionMirrors), 0)
// Blacklistable
reason = DisconnectIntroductionTimeout
setupTestOnDisconnect(d, c, mirror)
assert.NotPanics(t, func() { d.onGnetDisconnect(c, reason) })
assert.Equal(t, len(d.Peers.Peers.Blacklist), 1)
assert.NotNil(t, d.Peers.Peers.Blacklist[addr])
// Should be in blacklist
assert.Equal(t, len(d.Peers.Peers.Blacklist), 1)
assert.NotNil(t, d.Peers.Peers.Blacklist[addr])
// Should no longer be in OutgoingConnections
assert.Equal(t, len(d.OutgoingConnections), 0)
// Should no longer be in d.ExpectingIntroductions
assert.Equal(t, len(d.ExpectingIntroductions), 0)
// Should be removed from the mirror, and the mirror dict for this ip
// should be removed
assert.Equal(t, len(d.mirrorConnections), 0)
assert.Equal(t, len(d.ConnectionMirrors), 0)
// Cleanup
delete(d.Peers.Peers.Blacklist, addr)
// d.mirrorConnections should retain a submap if there are other ports
// inside
reason = gnet.DisconnectWriteFailed
setupTestOnDisconnect(d, c, mirror)
d.mirrorConnections[mirror][strings.Split(addrb, ":")[0]] = addrPort
assert.NotPanics(t, func() { d.onGnetDisconnect(c, reason) })
// Should not be in blacklist
assert.Equal(t, len(d.Peers.Peers.Blacklist), 0)
// Should no longer be in OutgoingConnections
assert.Equal(t, len(d.OutgoingConnections), 0)
// Should no longer be in d.ExpectingIntroductions
assert.Equal(t, len(d.ExpectingIntroductions), 0)
// Should be removed from the mirror, and the mirror dict for this ip
// should be removed
assert.Equal(t, len(d.mirrorConnections), 1)
assert.Equal(t, len(d.mirrorConnections[mirror]), 1)
assert.Equal(t, len(d.ConnectionMirrors), 0)
shutdown(d)
}
开发者ID:kinghuabg,项目名称:skycoin,代码行数:60,代码来源:daemon_test.go
示例12: TestGetPeersMessage
func TestGetPeersMessage(t *testing.T) {
d := newDefaultDaemon()
defer shutdown(d)
p := d.Pool
m := NewGetPeersMessage()
testSimpleMessageHandler(t, d, m)
d.Peers.Peers.AddPeer(addr)
q, err := d.Peers.Peers.AddPeer(addrb)
assert.Nil(t, err)
q.Private = true
d.Peers.Config.ReplyCount = 100
m.c = messageContext(addr)
// Peers disabled
d.Peers.Config.Disabled = true
assert.NotPanics(t, func() { m.Process(d) })
wait()
assert.Equal(t, len(p.Pool.SendResults), 0)
assert.True(t, m.c.Conn.LastSent.IsZero())
// Peers enabled
d.Peers.Config.Disabled = false
m.c = messageContext(addr)
defer m.c.Conn.Close()
go p.Pool.ConnectionWriteLoop(m.c.Conn)
assert.NotPanics(t, func() { m.Process(d) })
wait()
assert.Equal(t, len(p.Pool.SendResults), 1)
if len(p.Pool.SendResults) == 0 {
t.Fatal("SendResults empty, would block")
}
sr := <-p.Pool.SendResults
assert.Nil(t, sr.Error)
assert.Equal(t, sr.Connection, m.c.Conn)
msg, ok := sr.Message.(*GivePeersMessage)
assert.True(t, ok)
// Private peer should not be included
ipAddr, err := NewIPAddr(addr)
assert.Nil(t, err)
assert.Equal(t, msg.Peers, []IPAddr{ipAddr})
assert.False(t, m.c.Conn.LastSent.IsZero())
// If no peers, nothing should happen
m.c.Conn.LastSent = util.ZeroTime()
delete(d.Peers.Peers.Peerlist, addr)
assert.NotPanics(t, func() { m.Process(d) })
wait()
assert.Equal(t, len(p.Pool.SendResults), 0)
assert.True(t, m.c.Conn.LastSent.IsZero())
// Test serialization
m = NewGetPeersMessage()
b := encoder.Serialize(m)
m2 := GetPeersMessage{}
assert.Nil(t, encoder.DeserializeRaw(b, &m2))
assert.Equal(t, *m, m2)
gnet.EraseMessages()
}
开发者ID:Chao-Jia,项目名称:skycoin,代码行数:59,代码来源:messages_test.go
示例13: TestMustVersionByName
func TestMustVersionByName(t *testing.T) {
assert.Panics(t, func() { SetAddressVersion("bad") })
for k, _ := range addressVersions {
assert.NotPanics(t, func() { SetAddressVersion(k) })
}
assert.NotPanics(t, func() { SetAddressVersion("main") })
assert.NotPanics(t, func() { SetAddressVersion("test") })
}
开发者ID:RagnarDanneskjold,项目名称:skycoin,代码行数:8,代码来源:address_test.go
示例14: TestSingleUse
func TestSingleUse(t *testing.T) {
var s singleUse
assert.NotPanics(t, func() { s.ensureUnused("foo") })
assert.NotPanics(t, func() { s.use("foo") })
assert.Panics(t, func() { s.ensureUnused("foo") })
assert.Panics(t, func() { s.use("foo") })
}
开发者ID:yarpc,项目名称:yarpc-go,代码行数:9,代码来源:single_use_test.go
示例15: TestVisorSpend
func TestVisorSpend(t *testing.T) {
defer cleanupVisor()
defer gnet.EraseMessages()
p, gc := setupPool()
go p.Pool.ConnectionWriteLoop(gc)
vc, mv := setupVisor()
vc.Disabled = true
v := NewVisor(vc)
// Spending while disabled
assert.NotPanics(t, func() {
_, err := v.Spend(visor.Balance{10e6, 0}, 0,
mv.Wallet.GetAddresses()[0], p)
assert.NotNil(t, err)
assert.Equal(t, err.Error(), "Visor disabled")
wait()
assert.Equal(t, len(p.Pool.SendResults), 0)
assert.True(t, gc.LastSent.IsZero())
})
// Spending but spend fails (no money)
vc.Disabled = false
v = NewVisor(vc)
assert.NotPanics(t, func() {
_, err := v.Spend(visor.Balance{1000 * 10e6, 0}, 0,
mv.Wallet.GetAddresses()[0], p)
wait()
assert.NotNil(t, err)
assert.Equal(t, len(p.Pool.SendResults), 0)
assert.Equal(t, len(v.Visor.Unconfirmed.Txns), 0)
assert.True(t, gc.LastSent.IsZero())
})
// Spending succeeds, and announced
vc, mv = setupVisor()
vc.Disabled = false
gc.Conn = NewDummyConn(addr)
v = NewVisor(vc)
assert.Nil(t, transferCoins(mv, v.Visor))
assert.NotPanics(t, func() {
_, err := v.Spend(visor.Balance{10e6, 0}, 0,
mv.Wallet.GetAddresses()[0], p)
wait()
assert.Equal(t, len(p.Pool.SendResults), 1)
if len(p.Pool.SendResults) == 0 {
t.Fatal("SendResults empty, would block")
}
sr := <-p.Pool.SendResults
assert.Equal(t, sr.Connection, gc)
assert.Nil(t, sr.Error)
_, ok := sr.Message.(*GiveTxnsMessage)
assert.True(t, ok)
assert.Nil(t, err)
assert.Equal(t, len(v.Visor.Unconfirmed.Txns), 1)
assert.False(t, gc.LastSent.IsZero())
})
}
开发者ID:up4k,项目名称:skycoin,代码行数:56,代码来源:visor_test.go
示例16: TestRecover
func TestRecover(t *testing.T) {
var err error
// Nil type, should recover
assert.NotPanics(t, func() {
defer Recover(&err)
panic(nil)
})
assert.Equal(t, nil, err)
// Error type, should recover
assert.NotPanics(t, func() {
defer Recover(&err)
panic(io.EOF)
})
assert.Equal(t, io.EOF, err)
// Non error type, should panic
assert.Panics(t, func() {
defer Recover(&err)
panic(5)
})
// Runtime error, should panic
assert.Panics(t, func() {
defer Recover(&err)
var s string = "abc"
_ = s[100]
})
// Runtime error, should panic
assert.Panics(t, func() {
defer Recover(&err)
var s interface{} = "abc"
_ = s.(int)
})
// Runtime error, should panic
assert.Panics(t, func() {
defer Recover(&err)
cnt := -1
_ = make([]byte, cnt)
})
// Non-error, should panic
assert.Panics(t, func() {
defer Recover(&err)
panic((*int)(nil))
})
// Non-error, should panic
assert.Panics(t, func() {
defer Recover(&err)
panic(([]byte)(nil))
})
}
开发者ID:dsnet,项目名称:golib,代码行数:56,代码来源:errs_test.go
示例17: TestRecordBlockchainLength
func TestRecordBlockchainLength(t *testing.T) {
defer cleanupVisor()
vc, _ := setupVisor()
v := NewVisor(vc)
assert.NotPanics(t, func() { v.recordBlockchainLength(addr, uint64(6)) })
assert.Equal(t, v.blockchainLengths[addr], uint64(6))
v.blockchainLengths[addr] = uint64(7)
assert.NotPanics(t, func() { v.recordBlockchainLength(addr, uint64(5)) })
assert.Equal(t, v.blockchainLengths[addr], uint64(5))
}
开发者ID:up4k,项目名称:skycoin,代码行数:10,代码来源:visor_test.go
示例18: TestContextRenderRedirectAll
func TestContextRenderRedirectAll(t *testing.T) {
c, _, _ := CreateTestContext()
c.Request, _ = http.NewRequest("POST", "http://example.com", nil)
assert.Panics(t, func() { c.Redirect(200, "/resource") })
assert.Panics(t, func() { c.Redirect(202, "/resource") })
assert.Panics(t, func() { c.Redirect(299, "/resource") })
assert.Panics(t, func() { c.Redirect(309, "/resource") })
assert.NotPanics(t, func() { c.Redirect(300, "/resource") })
assert.NotPanics(t, func() { c.Redirect(308, "/resource") })
}
开发者ID:aclisp,项目名称:kubecon,代码行数:10,代码来源:context_test.go
示例19: TestConfigPreprocess
func TestConfigPreprocess(t *testing.T) {
c := NewConfig()
a := "127.0.0.1"
p := 7779
// Test that addr, port are copied to subconfigs
c.Daemon.Port = p
c.Daemon.Address = a
d := c.preprocess()
assert.Equal(t, d.Pool.port, p)
assert.Equal(t, d.Pool.address, a)
assert.Equal(t, d.DHT.port, p)
// Test localhost only with localhost addr
c = NewConfig()
c.Daemon.LocalhostOnly = true
c.Daemon.Address = a
assert.NotPanics(t, func() { c.preprocess() })
d = c.preprocess()
assert.True(t, d.DHT.Disabled)
assert.Equal(t, d.Pool.address, a)
assert.True(t, d.Peers.AllowLocalhost)
// Test localhost only with unassigned addr
c = NewConfig()
c.Daemon.LocalhostOnly = true
c.Daemon.Address = ""
assert.NotPanics(t, func() { c.preprocess() })
d = c.preprocess()
assert.True(t, IsLocalhost(d.Daemon.Address))
assert.True(t, IsLocalhost(d.Pool.address))
assert.True(t, d.Peers.AllowLocalhost)
// Test localhost only with nonlocal addr
c = NewConfig()
c.Daemon.LocalhostOnly = true
c.Daemon.Address = "11.22.33.44"
assert.Panics(t, func() { c.preprocess() })
// Test disable networking disables all
c = NewConfig()
c.Daemon.DisableNetworking = true
d = c.preprocess()
assert.True(t, d.Daemon.DisableNetworking)
assert.True(t, d.Daemon.DisableOutgoingConnections)
assert.True(t, d.Daemon.DisableIncomingConnections)
assert.True(t, d.DHT.Disabled)
assert.True(t, d.Peers.Disabled)
// Test coverage for logging statements
c = NewConfig()
c.Daemon.DisableNetworking = false
c.Daemon.DisableIncomingConnections = true
c.Daemon.DisableOutgoingConnections = true
assert.NotPanics(t, func() { c.preprocess() })
}
开发者ID:kinghuabg,项目名称:skycoin,代码行数:55,代码来源:daemon_test.go
示例20: TestTarFileIteratorClose
// Should be able to close repeatedly without panic.
func TestTarFileIteratorClose(t *testing.T) {
_, filename, _, _ := runtime.Caller(0)
tarFilePath, _ := filepath.Abs(path.Join(filepath.Dir(filename),
"..", "..", "testdata", "unit_test_bags", "example.edu.tagsample_good.tar"))
tfi, _ := fileutil.NewTarFileIterator(tarFilePath)
if tfi == nil {
assert.Fail(t, "Could not get TarFileIterator")
}
assert.NotPanics(t, tfi.Close, "TarFileIterator.Close() freaked out")
assert.NotPanics(t, tfi.Close, "TarFileIterator.Close() freaked out")
}
开发者ID:APTrust,项目名称:exchange,代码行数:12,代码来源:tar_file_iterator_test.go
注:本文中的github.com/stretchr/testify/assert.NotPanics函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论