コード例 #1
0
ファイル: util_test.go プロジェクト: tychofreeman/Linear
func TestFailIfEqualToWithUnequalInts(t *testing.T) {
	t2 := new(testing.T)
	Fail(t2).If(intsAreEqual(6, 5))
	if t2.Failed() {
		t.Error()
	}
}
コード例 #2
0
ファイル: etcd.go プロジェクト: Xmagicer/origin
func DumpEtcdOnFailure(t *testing.T) {
	if !t.Failed() {
		return
	}

	pc := make([]uintptr, 10)
	goruntime.Callers(2, pc)
	f := goruntime.FuncForPC(pc[0])
	last := strings.LastIndex(f.Name(), "Test")
	if last == -1 {
		last = 0
	}
	name := f.Name()[last:]

	client := NewEtcdClient()
	etcdResponse, err := client.RawGet("/", false, true)
	if err != nil {
		t.Logf("error dumping etcd: %v", err)
		return
	}

	if err := ioutil.WriteFile(GetBaseDir()+"/etcd-dump-"+name+".json", etcdResponse.Body, os.FileMode(0444)); err != nil {
		t.Logf("error dumping etcd: %v", err)
		return
	}
}
コード例 #3
0
ファイル: ofb_test.go プロジェクト: 2thetop/go
func TestOFB(t *testing.T) {
	for _, tt := range ofbTests {
		test := tt.name

		c, err := aes.NewCipher(tt.key)
		if err != nil {
			t.Errorf("%s: NewCipher(%d bytes) = %s", test, len(tt.key), err)
			continue
		}

		for j := 0; j <= 5; j += 5 {
			plaintext := tt.in[0 : len(tt.in)-j]
			ofb := cipher.NewOFB(c, tt.iv)
			ciphertext := make([]byte, len(plaintext))
			ofb.XORKeyStream(ciphertext, plaintext)
			if !bytes.Equal(ciphertext, tt.out[:len(plaintext)]) {
				t.Errorf("%s/%d: encrypting\ninput % x\nhave % x\nwant % x", test, len(plaintext), plaintext, ciphertext, tt.out)
			}
		}

		for j := 0; j <= 5; j += 5 {
			ciphertext := tt.out[0 : len(tt.in)-j]
			ofb := cipher.NewOFB(c, tt.iv)
			plaintext := make([]byte, len(ciphertext))
			ofb.XORKeyStream(plaintext, ciphertext)
			if !bytes.Equal(plaintext, tt.in[:len(ciphertext)]) {
				t.Errorf("%s/%d: decrypting\nhave % x\nwant % x", test, len(ciphertext), plaintext, tt.in)
			}
		}

		if t.Failed() {
			break
		}
	}
}
コード例 #4
0
ファイル: describe_test.go プロジェクト: lukaszb/goblin
func TestMultipleAfter(t *testing.T) {
	fakeTest := testing.T{}

	g := Goblin(&fakeTest)

	after := 0
	g.Describe("Numbers", func() {

		g.After(func() {
			after++
		})

		g.After(func() {
			after++
		})

		g.It("Should call all the registered after", func() {
			g.Assert(after).Equal(0)
		})
	})

	if fakeTest.Failed() && after != 2 {
		t.Fatal("Failed")
	}
}
コード例 #5
0
ファイル: describe_test.go プロジェクト: lukaszb/goblin
func TestMultipleBefore(t *testing.T) {
	fakeTest := testing.T{}

	g := Goblin(&fakeTest)

	g.Describe("Numbers", func() {
		before := 0

		g.Before(func() {
			before++
		})

		g.Before(func() {
			before++
		})

		g.It("Should have called all the registered before", func() {
			g.Assert(before).Equal(2)
		})
	})

	if fakeTest.Failed() {
		t.Fatal("Failed")
	}
}
コード例 #6
0
ファイル: ctr_aes_test.go プロジェクト: Greentor/go
func TestCTR_AES(t *testing.T) {
	for _, tt := range ctrAESTests {
		test := tt.name

		c, err := aes.NewCipher(tt.key)
		if err != nil {
			t.Errorf("%s: NewCipher(%d bytes) = %s", test, len(tt.key), err)
			continue
		}

		for j := 0; j <= 5; j += 5 {
			in := tt.in[0 : len(tt.in)-j]
			ctr := cipher.NewCTR(c, tt.iv)
			encrypted := make([]byte, len(in))
			ctr.XORKeyStream(encrypted, in)
			if out := tt.out[0:len(in)]; !bytes.Equal(out, encrypted) {
				t.Errorf("%s/%d: CTR\ninpt %x\nhave %x\nwant %x", test, len(in), in, encrypted, out)
			}
		}

		for j := 0; j <= 7; j += 7 {
			in := tt.out[0 : len(tt.out)-j]
			ctr := cipher.NewCTR(c, tt.iv)
			plain := make([]byte, len(in))
			ctr.XORKeyStream(plain, in)
			if out := tt.in[0:len(in)]; !bytes.Equal(out, plain) {
				t.Errorf("%s/%d: CTRReader\nhave %x\nwant %x", test, len(out), plain, out)
			}
		}

		if t.Failed() {
			break
		}
	}
}
コード例 #7
0
ファイル: github_archive_test.go プロジェクト: jhannah/grim
func TestUnarchiveRepo(t *testing.T) {
	temp, err := ioutil.TempDir("", "unarchive-repo-test")
	clonePath := "go/src/github.com/baz/foo.bar"
	cloned := filepath.Join(temp, clonePath)

	wd, _ := os.Getwd()
	file := fmt.Sprintf("%s/test_data/TestUnarchiveRepo/baz-foo.bar-v4.0.3-44-fasdfadsflkjlkjlkjlkjlkjlkjlj.tar.gz", wd)
	unpacked, err := unarchiveRepo(file, temp, clonePath, testBuildtimeout)

	if err != nil {
		t.Errorf("|%v|", err)
	}

	if unpacked != cloned {
		t.Errorf("Should have been %s was %s", cloned, unpacked)
	}

	files, err := ioutil.ReadDir(cloned)
	if err != nil {
		t.Errorf("|%v|", err)
	}

	if len(files) != 2 {
		t.Errorf("Directory %s had %v files.", cloned, len(files))
	}

	if !t.Failed() {
		//only remove output on success
		os.RemoveAll(temp)
	}

}
コード例 #8
0
func TestOneHostVlan_regress(t *testing.T) {
	defer func() {
		utils.ConfigCleanupCommon(t, testbed.GetNodes())
		utils.StopOnError(t.Failed())
	}()

	cfgFile := utils.GetCfgFile("one_host_vlan")
	jsonCfg, err := ioutil.ReadFile(cfgFile)
	if err != nil {
		t.Fatalf("failed to read config file %s \n", err)
	}
	utils.ConfigSetupCommon(t, string(jsonCfg), testbed.GetNodes())

	node1 := testbed.GetNodes()[0]

	utils.StartServer(t, node1, "myContainer1")
	defer func() {
		utils.DockerCleanup(t, node1, "myContainer1")
	}()

	ipAddress := utils.GetIPAddress(t, node1, "orange-myContainer1", u.EtcdNameStr)
	utils.StartClient(t, node1, "myContainer2", ipAddress)
	defer func() {
		utils.DockerCleanup(t, node1, "myContainer2")
	}()
}
コード例 #9
0
ファイル: couch_test.go プロジェクト: edwardoid/couch
func TestIntegrationInsert(t *testing.T) {
	db := setUpDatabase(t)
	defer tearDownDatabase(db, t)

	// Add new document
	doc := &Person{Name: "Peter", Height: 185, Alive: true}
	err := db.Insert(doc)
	if err != nil {
		t.Fatal("Inserted new document, error:", err)
	}
	if doc.ID == "" {
		t.Error("Inserted new document, should have ID set. Doc:", doc)
	}
	if doc.Rev == "" {
		t.Error("Inserted new document, should have Rev set. Doc:", doc)
	}

	if t.Failed() {
		t.FailNow()
	}

	// Edit existing
	oldID, oldRev := doc.ID, doc.Rev
	doc.Alive = false
	err = db.Insert(doc)
	if doc.Rev == oldRev {
		t.Error("Edited existing document, should have different rev. Doc:", doc)
	}
	if doc.ID != oldID {
		t.Error("Edited existing document, should have same id. Old:", oldID, "New:", doc.ID, doc)
	}
	if err != nil {
		t.Fatal("Edited existing document, error:", err)
	}
}
コード例 #10
0
ファイル: got_test.go プロジェクト: jmervine/env
func TestRefuteNil(t *testing.T) {
	T := new(testing.T) // Stub
	Go(T).RefuteNil(1, "should refute nil on int")
	if T.Failed() {
		t.Error("RefuteNil should not have failed.")
	}

	T = new(testing.T) // Stub
	Go(T).RefuteNil("a", "should refute nil on string")
	if T.Failed() {
		t.Error("RefuteNil should not have failed.")
	}

	T = new(testing.T) // Stub
	arr := []string{"a", "b"}
	Go(T).RefuteNil(arr, "should refute nil on array")
	if T.Failed() {
		t.Error("RefuteNil should not have failed.")
	}

	T = new(testing.T) // Stub
	var iface interface{}
	iface = "a"
	Go(T).RefuteNil(iface, "should refute nil on interface")
	if T.Failed() {
		t.Error("RefuteNil should not have failed.")
	}

	T = new(testing.T) // Stub
	Go(T).RefuteNil(nil, "should refute nil on int")
	if !T.Failed() {
		t.Error("RefuteNil should have failed.")
	}
}
コード例 #11
0
func TestStorage_create(t *testing.T) {
	_, err := NewStorage("tests.db", true)
	if err != nil {
		t.Failed()
	}

}
コード例 #12
0
ファイル: got_test.go プロジェクト: jmervine/env
func TestAssertDeepEqual(t *testing.T) {
	T := new(testing.T) // Stub
	Go(T).AssertDeepEqual(1, 1, "should assert deep equal int")
	if T.Failed() {
		t.Error("AssertDeepEqual should not have failed.")
	}

	T = new(testing.T) // Stub
	Go(T).AssertDeepEqual(1.0, 1.0)
	if T.Failed() {
		t.Error("AssertDeepEqual should not have failed.")
	}

	T = new(testing.T) // Stub
	m1 := map[string]string{"a": "a"}
	m2 := map[string]string{"a": "a"}
	Go(T).AssertDeepEqual(m1, m2, "should assert deep equal map")
	if T.Failed() {
		t.Error("AssertDeepEqual should not have failed.")
	}

	T = new(testing.T) // Stub
	a1 := []string{"a", "b"}
	a2 := []string{"a", "b"}
	Go(T).AssertDeepEqual(a1, a2, "should assert deep equal array")
	if T.Failed() {
		t.Error("AssertDeepEqual should not have failed.")
	}

	T = new(testing.T) // Stub
	Go(T).AssertDeepEqual(1, 2, "should assert deep equal int")
	if !T.Failed() {
		t.Error("AssertDeepEqual should have failed.")
	}
}
コード例 #13
0
ファイル: it_test.go プロジェクト: lukaszb/goblin
func TestNestedBeforeEach(t *testing.T) {
	fakeTest := testing.T{}

	g := Goblin(&fakeTest)

	g.Describe("Numbers", func() {
		before := 0

		g.BeforeEach(func() {
			before++
		})

		g.Describe("Addition", func() {
			g.BeforeEach(func() {
				before++
			})

			g.It("Should have called all the registered beforeEach", func() {
				g.Assert(before).Equal(2)
			})

			g.It("Should have called all the registered beforeEach also for this one", func() {
				g.Assert(before).Equal(4)
			})
		})

	})

	if fakeTest.Failed() {
		t.Fatal("Failed")
	}
}
コード例 #14
0
ファイル: t_bh16_main.go プロジェクト: PaddySchmidt/gofem
func main() {

	// catch errors
	var tst testing.T
	defer func() {
		if mpi.Rank() == 0 {
			if err := recover(); err != nil {
				io.PfRed("ERROR: %v\n", err)
			}
			if tst.Failed() {
				io.PfRed("test failed\n")
			}
		}
		mpi.Stop(false)
	}()
	mpi.Start(false)

	// start global variables and log
	analysis := fem.NewFEM("data/bh16.sim", "", true, true, false, true, true, 0)

	// run simulation
	err := analysis.Run()
	if err != nil {
		tst.Error("Run failed\n")
		return
	}

	// check
	skipK := true
	tolK := 1e-12
	tolu := 1e-15
	tols := 1e-12
	fem.TestingCompareResultsU(&tst, "data/bh16.sim", "cmp/bh16.cmp", "", tolK, tolu, tols, skipK, true)
}
コード例 #15
0
func TestBlock(t *testing.T) {
	if err := bakupIptables(); err != nil {
		t.Fatalf("Backup iptables error [%s]\n", err)
	}
	if err := restoreTp(RULETP, ACCEPT); err != nil {
		t.Fatalf("Restore iptables template error [%s]\n", err)
	}
	rules, err := FetchAll()
	if err != nil {
		t.Fatalf("Fetch all rules error [%s]\n", err)
	}
	for id, _ := range rules {
		Block(id)
	}
	if err := Update(); err != nil {
		t.Fatalf("Update rules error [%s]\n", err)
	}
	rules, err = FetchAll()
	if err != nil {
		t.Fatalf("Fetch all rules again error [%s]\n", err)
	}
	for id, rule := range rules {
		if rule.Status == ACCEPT {
			t.Errorf("Container [%s] is not blocked", id)
		}
	}
	restoreIptables(originalRule)
	if !t.Failed() {
		t.Log("Block Passed")
	}
	return
}
コード例 #16
0
ファイル: database_test.go プロジェクト: viking/go-keyrack
func tempfile(t *testing.T, fn func(filename string)) {
	var (
		f   *os.File
		err error
	)

	/* Create temporary file */
	f, err = ioutil.TempFile("", "keyrack")
	if err != nil {
		t.Error(err)
		return
	}
	err = f.Close()
	if err != nil {
		t.Error(err)
		return
	}

	fn(f.Name())

	if t.Failed() {
		t.Log(f.Name())
	} else {
		os.Remove(f.Name())
	}
}
コード例 #17
0
ファイル: issue10303.go プロジェクト: danny8002/go
func test10303(t *testing.T, n int) {
	if runtime.Compiler == "gccgo" {
		t.Skip("gccgo permits C pointers on the stack")
	}

	// Run at a few different stack depths just to avoid an unlucky pass
	// due to variables ending up on different pages.
	if n > 0 {
		test10303(t, n-1)
	}
	if t.Failed() {
		return
	}
	var x, y, z, v, si C.int
	var s C.Struct
	C.setintstar(&x)
	C.setintptr(&y)
	C.setvoidptr(unsafe.Pointer(&v))
	s.P = &si
	C.setstruct(s)

	if uintptr(unsafe.Pointer(&x))&^0xfff == uintptr(unsafe.Pointer(&z))&^0xfff {
		t.Error("C int* argument on stack")
	}
	if uintptr(unsafe.Pointer(&y))&^0xfff == uintptr(unsafe.Pointer(&z))&^0xfff {
		t.Error("C intptr argument on stack")
	}
	if uintptr(unsafe.Pointer(&v))&^0xfff == uintptr(unsafe.Pointer(&z))&^0xfff {
		t.Error("C void* argument on stack")
	}
	if uintptr(unsafe.Pointer(&si))&^0xfff == uintptr(unsafe.Pointer(&z))&^0xfff {
		t.Error("C struct field pointer on stack")
	}
}
コード例 #18
0
ファイル: api_test.go プロジェクト: seesawlabs/apitest
func TestRunApi(t *testing.T) {

	tests := []apitest.IApiTest{
		&GetUserTest{},
		&UpdateUserTest{},
		&CreateUserTest{},
		&DeleteUserTest{},
	}

	runner := apitest.NewRunner("http://localhost:1323", apitest.RunnerConfig{})
	runner.Run(t, tests...)

	if !t.Failed() {
		var writer io.Writer
		if outFile != nil && *outFile != "" {
			fo, err := os.Create(*outFile)
			if err != nil {
				panic(err)
			}
			// close fo on exit and check for its returned error
			defer func() {
				if err := fo.Close(); err != nil {
					panic(err)
				}
			}()

			writer = fo
		} else {
			writer = os.Stdout
		}
		generateSwaggerYAML(t, tests, writer)
	}
}
コード例 #19
0
ファイル: helpers_test.go プロジェクト: alex-mohr/kubernetes
func TestDumpReaderToFile(t *testing.T) {
	testString := "TEST STRING"
	tempFile, err := ioutil.TempFile("", "hlpers_test_dump_")
	if err != nil {
		t.Errorf("unexpected error setting up a temporary file %v", err)
	}
	defer syscall.Unlink(tempFile.Name())
	defer tempFile.Close()
	defer func() {
		if !t.Failed() {
			os.Remove(tempFile.Name())
		}
	}()
	err = DumpReaderToFile(strings.NewReader(testString), tempFile.Name())
	if err != nil {
		t.Errorf("error in DumpReaderToFile: %v", err)
	}
	data, err := ioutil.ReadFile(tempFile.Name())
	if err != nil {
		t.Errorf("error when reading %s: %v", tempFile.Name(), err)
	}
	stringData := string(data)
	if stringData != testString {
		t.Fatalf("Wrong file content %s != %s", testString, stringData)
	}
}
コード例 #20
0
ファイル: filestore_test.go プロジェクト: hotei/inbucket
// Test FileDataStore.AllMailboxes()
func TestFSAllMailboxes(t *testing.T) {
	ds, logbuf := setupDataStore(config.DataStoreConfig{})
	defer teardownDataStore(ds)

	for _, name := range []string{"abby", "bill", "christa", "donald", "evelyn"} {
		// Create day old message
		date := time.Now().Add(-24 * time.Hour)
		deliverMessage(ds, name, "Old Message", date)

		// Create current message
		date = time.Now()
		deliverMessage(ds, name, "New Message", date)
	}

	mboxes, err := ds.AllMailboxes()
	assert.Nil(t, err)
	assert.Equal(t, len(mboxes), 5)

	if t.Failed() {
		// Wait for handler to finish logging
		time.Sleep(2 * time.Second)
		// Dump buffered log data if there was a failure
		io.Copy(os.Stderr, logbuf)
	}
}
コード例 #21
0
ファイル: events_ccm_test.go プロジェクト: CrowdStrike/gocql
func TestEventDiscovery(t *testing.T) {
	if err := ccm.AllUp(); err != nil {
		t.Fatal(err)
	}

	session := createSession(t)
	defer session.Close()

	status, err := ccm.Status()
	if err != nil {
		t.Fatal(err)
	}
	t.Logf("status=%+v\n", status)

	session.pool.mu.RLock()
	poolHosts := session.pool.hostConnPools // TODO: replace with session.ring
	t.Logf("poolhosts=%+v\n", poolHosts)
	// check we discovered all the nodes in the ring
	for _, host := range status {
		if _, ok := poolHosts[host.Addr]; !ok {
			t.Errorf("did not discover %q", host.Addr)
		}
	}
	session.pool.mu.RUnlock()
	if t.Failed() {
		t.FailNow()
	}
}
コード例 #22
0
ファイル: filestore_test.go プロジェクト: hotei/inbucket
// Test delivering several messages to the same mailbox, see if no message cap works
func TestFSNoMessageCap(t *testing.T) {
	mbCap := 0
	ds, logbuf := setupDataStore(config.DataStoreConfig{MailboxMsgCap: mbCap})
	defer teardownDataStore(ds)

	mbName := "captain"
	for i := 0; i < 20; i++ {
		// Add a message
		subj := fmt.Sprintf("subject %v", i)
		deliverMessage(ds, mbName, subj, time.Now())
		t.Logf("Delivered %q", subj)

		// Check number of messages
		mb, err := ds.MailboxFor(mbName)
		if err != nil {
			t.Fatalf("Failed to MailboxFor(%q): %v", mbName, err)
		}
		msgs, err := mb.GetMessages()
		if err != nil {
			t.Fatalf("Failed to GetMessages for %q: %v", mbName, err)
		}
		if len(msgs) != i+1 {
			t.Errorf("Expected %v messages, got %v", i+1, len(msgs))
		}
	}

	if t.Failed() {
		// Wait for handler to finish logging
		time.Sleep(2 * time.Second)
		// Dump buffered log data if there was a failure
		io.Copy(os.Stderr, logbuf)
	}
}
コード例 #23
0
ファイル: describe_test.go プロジェクト: lukaszb/goblin
func TestNestedAfter(t *testing.T) {
	fakeTest := testing.T{}

	g := Goblin(&fakeTest)
	after := 0
	g.Describe("Numbers", func() {

		g.After(func() {
			after++
		})

		g.Describe("Addition", func() {
			g.After(func() {
				after++
			})

			g.It("Should call all the registered after", func() {
				g.Assert(after).Equal(0)
			})

			g.It("Should have called all the registered after only once", func() {
				g.Assert(after).Equal(0)
			})
		})

	})

	if fakeTest.Failed() || after != 2 {
		t.Fatal("Failed")
	}
}
コード例 #24
0
ファイル: t_p01_main.go プロジェクト: PatrickSchm/gofem
func main() {

	// catch errors
	var tst testing.T
	defer func() {
		if mpi.Rank() == 0 {
			if err := recover(); err != nil {
				io.PfRed("ERROR: %v\n", err)
			}
			if tst.Failed() {
				io.PfRed("test failed\n")
			}
		}
		mpi.Stop(false)
	}()
	mpi.Start(false)

	// start global variables and log
	if !fem.Start("data/p01.sim", true, true) {
		tst.Error("Start failed\n")
		return
	}

	// make sure to flush log
	defer fem.End()

	// run simulation
	if !fem.Run() {
		tst.Error("Run failed\n")
		return
	}
}
コード例 #25
0
ファイル: describe_test.go プロジェクト: lukaszb/goblin
func TestBefore(t *testing.T) {
	fakeTest := testing.T{}

	g := Goblin(&fakeTest)

	g.Describe("Numbers", func() {
		before := 0

		g.Before(func() {
			before++
		})

		g.It("Should have called before", func() {
			g.Assert(before).Equal(1)
		})

		g.It("Should have called before only once", func() {
			g.Assert(before).Equal(1)
		})
	})

	if fakeTest.Failed() {
		t.Fatal("Failed")
	}
}
コード例 #26
0
ファイル: it_test.go プロジェクト: kevin-cantwell/goblin
func TestBeforeEach(t *testing.T) {
	fakeTest := testing.T{}

	g := Goblin(&fakeTest)

	g.Describe("Numbers", func() {
		before := 0

		g.BeforeEach(func() {
			before++
		})

		g.It("Should have called beforeEach", func() {
			g.Assert(before).Equal(1)
		})

		g.It("Should have called beforeEach also for this one", func() {
			g.Assert(before).Equal(2)
		})
	})

	if fakeTest.Failed() {
		t.Fatal()
	}
}
コード例 #27
0
// checkRestart checks that there are no errors left to inject.
func checkRestarts(t *testing.T, magicVals *filterVals) {
	magicVals.Lock()
	defer magicVals.Unlock()
	for key, count := range magicVals.restartCounts {
		if count != 0 {
			file, line, _ := caller.Lookup(1)
			t.Errorf("%s:%d: INSERT for \"%s\" still has to be retried %d times",
				file, line, key, count)
		}
	}
	for key, count := range magicVals.abortCounts {
		if count != 0 {
			file, line, _ := caller.Lookup(1)
			t.Errorf("%s:%d: INSERT for \"%s\" still has to be aborted %d times",
				file, line, key, count)
		}
	}
	for key, count := range magicVals.endTxnRestartCounts {
		if count != 0 {
			file, line, _ := caller.Lookup(1)
			t.Errorf("%s:%d: txn writing \"%s\" still has to be aborted %d times",
				file, line, key, count)
		}
	}
	if len(magicVals.txnsToFail) > 0 {
		file, line, _ := caller.Lookup(1)
		t.Errorf("%s:%d: txns still to be failed: %v", file, line, magicVals.txnsToFail)
	}
	if t.Failed() {
		t.Fatalf("checking error injection failed")
	}
}
コード例 #28
0
ファイル: syscall_bsd_test.go プロジェクト: Rudloff/platform
func TestGetfsstat(t *testing.T) {
	const flags = MNT_NOWAIT // see golang.org/issue/16937
	n, err := unix.Getfsstat(nil, flags)
	if err != nil {
		t.Fatal(err)
	}

	data := make([]unix.Statfs_t, n)
	n2, err := unix.Getfsstat(data, flags)
	if err != nil {
		t.Fatal(err)
	}
	if n != n2 {
		t.Errorf("Getfsstat(nil) = %d, but subsequent Getfsstat(slice) = %d", n, n2)
	}
	for i, stat := range data {
		if stat == (unix.Statfs_t{}) {
			t.Errorf("index %v is an empty Statfs_t struct", i)
		}
	}
	if t.Failed() {
		for i, stat := range data[:n2] {
			t.Logf("data[%v] = %+v", i, stat)
		}
		mount, err := exec.Command("mount").CombinedOutput()
		if err != nil {
			t.Logf("mount: %v\n%s", err, mount)
		} else {
			t.Logf("mount: %s", mount)
		}
	}
}
コード例 #29
0
ファイル: router_test.go プロジェクト: aresLove/revel
// Run the test cases above.
func TestComputeRoute(t *testing.T) {
	for routeLine, expected := range routeTestCases {
		method, path, action, found := parseRouteLine(routeLine)
		if !found {
			t.Error("Failed to parse route line:", routeLine)
			continue
		}
		actual := NewRoute(method, path, action)
		eq(t, "Method", actual.Method, expected.Method)
		eq(t, "Path", actual.Path, expected.Path)
		eq(t, "Action", actual.Action, expected.Action)
		eq(t, "pathPattern", fmt.Sprint(actual.pathPattern), fmt.Sprint(expected.pathPattern))
		eq(t, "staticDir", actual.staticDir, expected.staticDir)
		eq(t, "len(args)", len(actual.args), len(expected.args))
		for i, arg := range actual.args {
			if len(expected.args) <= i {
				break
			}
			eq(t, "arg.name", arg.name, expected.args[i].name)
			eq(t, "arg.constraint", arg.constraint.String(), expected.args[i].constraint.String())
		}
		eq(t, "actionPattern", fmt.Sprint(actual.actionPattern), fmt.Sprint(expected.actionPattern))
		if t.Failed() {
			t.Fatal("Failed on route:", routeLine)
		}
	}
}
コード例 #30
0
ファイル: util_test.go プロジェクト: tychofreeman/Linear
func TestFailIfNotEqualToWithEqualInts(t *testing.T) {
	t2 := new(testing.T)
	Fail(t2).If(intsAreNotEqual(5, 5))
	if t2.Failed() {
		t.Error()
	}
}