本文整理汇总了Golang中testing.T.SkipNow方法的典型用法代码示例。如果您正苦于以下问题:Golang T.SkipNow方法的具体用法?Golang T.SkipNow怎么用?Golang T.SkipNow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类testing.T
的用法示例。
在下文中一共展示了T.SkipNow方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestNilInputs
// TestNilInputs tries supplying the renter with nil inputs and checks for
// correct rejection.
func TestNilInputs(t *testing.T) {
if testing.Short() {
t.SkipNow()
}
rt, err := newRenterTester("TestNilInputs")
if err != nil {
t.Fatal(err)
}
_, err = New(rt.cs, rt.hostdb, rt.wallet, rt.tpool, rt.renter.saveDir+"1")
if err != nil {
t.Error(err)
}
_, err = New(nil, nil, nil, nil, rt.renter.saveDir+"2")
if err == nil {
t.Error("no error returned for nil inputs")
}
_, err = New(nil, rt.hostdb, rt.wallet, rt.tpool, rt.renter.saveDir+"3")
if err != ErrNilCS {
t.Error(err)
}
_, err = New(rt.cs, nil, rt.wallet, rt.tpool, rt.renter.saveDir+"5")
if err != ErrNilHostDB {
t.Error(err)
}
_, err = New(rt.cs, rt.hostdb, nil, rt.tpool, rt.renter.saveDir+"6")
if err != ErrNilWallet {
t.Error(err)
}
_, err = New(rt.cs, rt.hostdb, rt.wallet, nil, rt.renter.saveDir+"6")
if err != ErrNilTpool {
t.Error(err)
}
}
示例2: TestDockerHostNet
func TestDockerHostNet(t *testing.T) {
if !dockerLocated() {
t.SkipNow()
}
task := &structs.Task{
Config: map[string]string{
"image": "redis",
"network_mode": "host",
},
Resources: &structs.Resources{
MemoryMB: 256,
CPU: 512,
},
}
driverCtx := testDriverContext(task.Name)
ctx := testDriverExecContext(task, driverCtx)
defer ctx.AllocDir.Destroy()
d := NewDockerDriver(driverCtx)
handle, err := d.Start(ctx, task)
if err != nil {
t.Fatalf("err: %v", err)
}
if handle == nil {
t.Fatalf("missing handle")
}
defer handle.Kill()
}
示例3: TestZookeeperBackend
func TestZookeeperBackend(t *testing.T) {
addr := os.Getenv("ZOOKEEPER_ADDR")
if addr == "" {
t.SkipNow()
}
client, _, err := zk.Connect([]string{addr}, time.Second)
if err != nil {
t.Fatalf("err: %v", err)
}
randPath := fmt.Sprintf("/vault-%d", time.Now().Unix())
acl := zk.WorldACL(zk.PermAll)
_, err = client.Create(randPath, []byte("hi"), int32(0), acl)
if err != nil {
t.Fatalf("err: %v", err)
}
defer func() {
client.Delete(randPath, -1)
}()
b, err := NewBackend("zookeeper", map[string]string{
"address": addr + "," + addr,
"path": randPath,
})
if err != nil {
t.Fatalf("err: %s", err)
}
testBackend(t, b)
testBackend_ListPrefix(t, b)
}
示例4: TestThreadGroupOnStop
// TestThreadGroupOnStop tests that Stop calls functions registered with
// OnStop.
func TestThreadGroupOnStop(t *testing.T) {
if testing.Short() {
t.SkipNow()
}
l, err := net.Listen("tcp", "localhost:0")
if err != nil {
t.Fatal(err)
}
// create ThreadGroup and register the closer
var tg ThreadGroup
tg.OnStop(func() { l.Close() })
// send on channel when listener is closed
var closed bool
tg.Add()
go func() {
defer tg.Done()
_, err := l.Accept()
closed = err != nil
}()
tg.Stop()
if !closed {
t.Fatal("Stop did not close listener")
}
}
示例5: NewAuthenticatedClient
// NewAuthenticatedClient creates a new vim25.Client, authenticates the user
// specified in the test URL, and returns it.
func NewAuthenticatedClient(t *testing.T) *vim25.Client {
u := URL()
if u == nil {
t.SkipNow()
}
soapClient := soap.NewClient(u, true)
vimClient, err := vim25.NewClient(context.Background(), soapClient)
if err != nil {
t.Fatal(err)
}
req := types.Login{
This: *vimClient.ServiceContent.SessionManager,
}
req.UserName = u.User.Username()
if pw, ok := u.User.Password(); ok {
req.Password = pw
}
_, err = methods.Login(context.Background(), vimClient, &req)
if err != nil {
t.Fatal(err)
}
return vimClient
}
示例6: TestTryInvalidTransactionSet
// TestTryInvalidTransactionSet submits an invalid transaction set to the
// TryTransaction method.
func TestTryInvalidTransactionSet(t *testing.T) {
if testing.Short() {
t.SkipNow()
}
cst, err := createConsensusSetTester("TestValidTransaction")
if err != nil {
t.Fatal(err)
}
defer cst.Close()
initialHash := cst.cs.dbConsensusChecksum()
// Try a valid transaction followed by an invalid transaction.
_, err = cst.wallet.SendSiacoins(types.NewCurrency64(1), types.UnlockHash{})
if err != nil {
t.Fatal(err)
}
txns := cst.tpool.TransactionList()
txn := types.Transaction{
SiacoinInputs: []types.SiacoinInput{{}},
}
txns = append(txns, txn)
cc, err := cst.cs.TryTransactionSet(txns)
if err == nil {
t.Error("bad transaction survived filter")
}
if cst.cs.dbConsensusChecksum() != initialHash {
t.Error("TryTransactionSet did not restore order")
}
if len(cc.SiacoinOutputDiffs) != 0 {
t.Error("consensus change was not empty despite an error being returned")
}
}
示例7: TestThreadGroupStopEarly
// TestThreadGroupStopEarly tests that a thread group can correctly interrupt
// an ongoing process.
func TestThreadGroupStopEarly(t *testing.T) {
if testing.Short() {
t.SkipNow()
}
t.Parallel()
var tg ThreadGroup
for i := 0; i < 10; i++ {
err := tg.Add()
if err != nil {
t.Fatal(err)
}
go func() {
defer tg.Done()
select {
case <-time.After(1 * time.Second):
case <-tg.StopChan():
}
}()
}
start := time.Now()
err := tg.Stop()
elapsed := time.Since(start)
if err != nil {
t.Fatal(err)
} else if elapsed > 100*time.Millisecond {
t.Fatal("Stop did not interrupt goroutines")
}
}
示例8: TestSizeSplitterIsDeterministic
func TestSizeSplitterIsDeterministic(t *testing.T) {
if testing.Short() {
t.SkipNow()
}
test := func() {
bufR := randBuf(t, 10000000) // crank this up to satisfy yourself.
bufA := copyBuf(bufR)
bufB := copyBuf(bufR)
chunksA := DefaultSplitter.Split(bytes.NewReader(bufA))
chunksB := DefaultSplitter.Split(bytes.NewReader(bufB))
for n := 0; ; n++ {
a, moreA := <-chunksA
b, moreB := <-chunksB
if !moreA {
if moreB {
t.Fatal("A ended, B didnt.")
}
return
}
if !bytes.Equal(a, b) {
t.Fatalf("chunk %d not equal", n)
}
}
}
for run := 0; run < 1; run++ { // crank this up to satisfy yourself.
test()
}
}
示例9: TestSizeSplitterFillsChunks
func TestSizeSplitterFillsChunks(t *testing.T) {
if testing.Short() {
t.SkipNow()
}
max := 10000000
b := randBuf(t, max)
r := &clipReader{r: bytes.NewReader(b), size: 4000}
s := SizeSplitter{Size: 1024 * 256}
c := s.Split(r)
sofar := 0
whole := make([]byte, max)
for chunk := range c {
bc := b[sofar : sofar+len(chunk)]
if !bytes.Equal(bc, chunk) {
t.Fatalf("chunk not correct: (sofar: %d) %d != %d, %v != %v", sofar, len(bc), len(chunk), bc[:100], chunk[:100])
}
copy(whole[sofar:], chunk)
sofar += len(chunk)
if sofar != max && len(chunk) < s.Size {
t.Fatal("sizesplitter split at a smaller size")
}
}
if !bytes.Equal(b, whole) {
t.Fatal("splitter did not split right")
}
}
示例10: TestIntegrationMinerGET
// TestIntegrationMinerGET checks the GET call to the /miner endpoint.
func TestIntegrationMinerGET(t *testing.T) {
if testing.Short() {
t.SkipNow()
}
st, err := createServerTester("TestIntegrationMinerGET")
if err != nil {
t.Fatal(err)
}
defer st.server.Close()
// Get the api returned fields of the miner.
var mg MinerGET
err = st.getAPI("/miner", &mg)
if err != nil {
t.Fatal(err)
}
// Verify the correctness of the results.
blocksMined, staleBlocksMined := st.server.api.miner.BlocksMined()
if mg.BlocksMined != blocksMined {
t.Error("blocks mined did not succeed")
}
if mg.StaleBlocksMined != staleBlocksMined {
t.Error("stale blocks mined is incorrect")
}
if mg.CPUHashrate != st.server.api.miner.CPUHashrate() {
t.Error("mismatched cpu hashrate")
}
if mg.CPUMining != st.server.api.miner.CPUMining() {
t.Error("mismatched cpu miner status")
}
}
示例11: TestArchiveSpaceAPI
func TestArchiveSpaceAPI(t *testing.T) {
// Get the environment variables needed for testing.
isSetup := checkConfig(t)
if isSetup == false {
t.Error("Environment variables needed to run tests not configured", isSetup)
t.SkipNow()
}
cait := New(caitURL, caitUsername, caitPassword)
if cait.BaseURL == nil {
t.Errorf("%s\t%s", cait.BaseURL.String(), caitURL)
}
if strings.Compare(cait.BaseURL.String(), fmt.Sprintf("%s", caitURL)) != 0 {
t.Errorf("%s != %s\n", cait.BaseURL.String(), caitURL)
}
if cait.IsAuth() == true {
t.Error("cait.IsAuth() returning true before authentication")
}
err := cait.Login()
if err != nil {
t.Errorf("%s\t%s", err, cait.BaseURL.String())
t.FailNow()
}
if cait.IsAuth() == false {
t.Error("cait.IsAuth() return false after authentication")
}
err = cait.Logout()
if err != nil {
t.Errorf("Logout() %s", err)
}
}
示例12: TestFluentdHandlerOutput
func TestFluentdHandlerOutput(t *testing.T) {
if fluentdAddr == "" {
t.SkipNow()
}
testHandlerOutput(t, NewFluentdHandler(fluentdAddr, "rglog.test"))
}
示例13: TestFileSaveLoadASCII
// TestFileSaveLoadASCII tests the ASCII saving/loading functions.
func TestFileSaveLoadASCII(t *testing.T) {
if testing.Short() {
t.SkipNow()
}
rt, err := newRenterTester("TestRenterSaveLoad")
if err != nil {
t.Fatal(err)
}
defer rt.Close()
// Create a file and add it to the renter.
savedFile := newTestingFile()
rt.renter.files[savedFile.name] = savedFile
ascii, err := rt.renter.ShareFilesAscii([]string{savedFile.name})
if err != nil {
t.Fatal(err)
}
// Remove the file from the renter.
delete(rt.renter.files, savedFile.name)
names, err := rt.renter.LoadSharedFilesAscii(ascii)
if err != nil {
t.Fatal(err)
}
if len(names) != 1 || names[0] != savedFile.name {
t.Fatal("nickname not loaded properly")
}
err = equalFiles(rt.renter.files[savedFile.name], savedFile)
if err != nil {
t.Fatal(err)
}
}
示例14: dockerSetup
// dockerSetup does all of the basic setup you need to get a running docker
// process up and running for testing. Use like:
//
// task := taskTemplate()
// // do custom task configuration
// client, handle, cleanup := dockerSetup(t, task)
// defer cleanup()
// // do test stuff
//
// If there is a problem during setup this function will abort or skip the test
// and indicate the reason.
func dockerSetup(t *testing.T, task *structs.Task) (*docker.Client, DriverHandle, func()) {
if !testutil.DockerIsConnected(t) {
t.SkipNow()
}
client, err := docker.NewClientFromEnv()
if err != nil {
t.Fatalf("Failed to initialize client: %s\nStack\n%s", err, debug.Stack())
}
driverCtx, execCtx := testDriverContexts(task)
driver := NewDockerDriver(driverCtx)
handle, err := driver.Start(execCtx, task)
if err != nil {
execCtx.AllocDir.Destroy()
t.Fatalf("Failed to start driver: %s\nStack\n%s", err, debug.Stack())
}
if handle == nil {
execCtx.AllocDir.Destroy()
t.Fatalf("handle is nil\nStack\n%s", debug.Stack())
}
cleanup := func() {
handle.Kill()
execCtx.AllocDir.Destroy()
}
return client, handle, cleanup
}
示例15: TestGetclient
func TestGetclient(t *testing.T) {
t.SkipNow()
server := "http://127.0.0.1:9200/"
client, err := Getclient(server)
if err != nil {
fmt.Println("fail to create the client:", err)
return
}
fmt.Println(client)
// Create an index
//_, err = client.CreateIndex("testagent").Do()
if err != nil {
fmt.Println(err)
return
}
message := &Test{Testa: "Testing messages a", Testb: "Testing message b", Testc: 100}
//client.Push(message, "Test")
jsonmessage, err := json.Marshal(message)
if err != nil {
fmt.Println(err)
return
}
fmt.Println("json message:", string(jsonmessage))
err = client.Push(jsonmessage, "Testindex", "Testtype")
if err != nil {
fmt.Println(err)
}
}