コード例 #1
1
ファイル: fsrepo_test.go プロジェクト: andradeandrey/go-ipfs
func TestCanManageReposIndependently(t *testing.T) {
	t.Parallel()
	pathA := testRepoPath("a", t)
	pathB := testRepoPath("b", t)

	t.Log("initialize two repos")
	assert.Nil(Init(pathA, &config.Config{}), t, "a", "should initialize successfully")
	assert.Nil(Init(pathB, &config.Config{}), t, "b", "should initialize successfully")

	t.Log("ensure repos initialized")
	assert.True(IsInitialized(pathA), t, "a should be initialized")
	assert.True(IsInitialized(pathB), t, "b should be initialized")

	t.Log("open the two repos")
	repoA, err := Open(pathA)
	assert.Nil(err, t, "a")
	repoB, err := Open(pathB)
	assert.Nil(err, t, "b")

	t.Log("close and remove b while a is open")
	assert.Nil(repoB.Close(), t, "close b")
	assert.Nil(Remove(pathB), t, "remove b")

	t.Log("close and remove a")
	assert.Nil(repoA.Close(), t)
	assert.Nil(Remove(pathA), t)
}
コード例 #2
1
func TestCalibrateThreshold(t *testing.T) {
	if !*calibrate {
		t.Log("not calibrating, use -calibrate to do so.")
		return
	}

	lower := int(1e3)   // math/big is faster at this size.
	upper := int(300e3) // FFT is faster at this size.

	big, fft := measureMul(lower)
	lowerX := float64(big) / float64(fft)
	fmt.Printf("speedup at size %d: %.2f\n", lower, lowerX)
	big, fft = measureMul(upper)
	upperX := float64(big) / float64(fft)
	fmt.Printf("speedup at size %d: %.2f\n", upper, upperX)
	for {
		mid := (lower + upper) / 2
		big, fft := measureMul(mid)
		X := float64(big) / float64(fft)
		fmt.Printf("speedup at size %d: %.2f\n", mid, X)
		switch {
		case X < 0.98:
			lower = mid
			lowerX = X
		case X > 1.02:
			upper = mid
			upperX = X
		default:
			fmt.Printf("speedup at size %d: %.2f\n", lower, lowerX)
			fmt.Printf("speedup at size %d: %.2f\n", upper, upperX)
			return
		}
	}
}
コード例 #3
0
ファイル: cache_test.go プロジェクト: berkus/completion
func TestCacheComplete(t *testing.T) {
	paths := DefaultPaths()
	if len(paths) == 0 {
		t.Skip("No default paths available")
	}

	tests := []string{"mscorlib.dll", "System.dll"}

	t.Log(paths)
	c := Cache{paths: paths}
	for _, test := range tests {
		if asm, err := c.Load(test); err != nil {
			t.Error(err)
		} else {
			t.Logf("Found %s (%s)", test, asm.Name())
		}
	}

	tests2 := []content.Type{
		content.Type{Name: content.FullyQualifiedName{Absolute: "net://type/System.String"}},
	}
	for _, test := range tests2 {
		if res, err := c.Complete(&test); err != nil {
			t.Error(err)
		} else {
			t.Log(res)
		}
	}
}
コード例 #4
0
ファイル: list_test.go プロジェクト: Mooxe000/GoDash
func Test_RemoveList(t *testing.T) {
	FuncName := "GdLists.RemoveList()"

	ssgl, _ := getGdListIns()
	Pssgl := &ssgl
	Pssgl.New()

	// -- a == b == 0
	// s, e, _ := 0, 0, 5        // 2, 3, 4, 5

	// -- a == b == l - 1
	// s, e = 4, 4               // 1, 2, 3, 4
	// -- a == 0 && b == l - 1
	// s, e = 0, 4               // nil
	// -- 0 < a < b < l
	// s, e = 1, 3               // 1, 5
	// a = 0
	// s, e = 0, 2               // 4, 5
	// b = l - 1
	// s, e = 2, 4               // 1, 2

	// Pssgl.RemoveList(s, e)

	// dd(Pssgl.Sync().Value)

	t.Log(FuncName + " ... ok!")
}
コード例 #5
0
ファイル: list_test.go プロジェクト: Mooxe000/GoDash
func Test_seCheck(t *testing.T) {
	FuncName := "GdLists.seCheck()"

	// -- a == b == 0
	// s, e, l := 0, 0, 5       // 0, 0

	// -- a < 0 && b < 0
	// s, e = -5, -10           // 0, 0
	// -- a >=l && b >= l
	// s, e = 5, 10             // 4, 4
	// -- a < 0 && b >= l
	// s, e = -5, 10            // 0, 4
	// -- a < 0 && b >= 0
	// s, e = -5, 2             // 0, 2
	// -- a >= 0 && b >= l
	// s, e = 2, 10             // 2, 4

	// -- a == b == l - 1
	// s, e = 4, 4              // 4, 4
	// -- a == 0 && b == l - 1
	// s, e = 0, 4              // 0, 4
	// -- 0 < a < b < l
	// s, e = 1, 3              // 1, 3
	// -- a = 0
	// s, e = 0, 2              // 0, 2
	// -- b = l - 1
	// s, e = 2, 4              // 2, 4

	// a, b := seCheck(s, e, l)
	// dd(a)
	// dd(b)

	t.Log(FuncName + " ... ok!")
}
コード例 #6
0
ファイル: walk_test.go プロジェクト: qbit/syncthing
func TestWalk(t *testing.T) {
	ignores := ignore.New(false)
	err := ignores.Load("testdata/.stignore")
	if err != nil {
		t.Fatal(err)
	}
	t.Log(ignores)

	w := Walker{
		Dir:       "testdata",
		BlockSize: 128 * 1024,
		Matcher:   ignores,
	}

	fchan, err := w.Walk()
	if err != nil {
		t.Fatal(err)
	}

	var tmp []protocol.FileInfo
	for f := range fchan {
		tmp = append(tmp, f)
	}
	sort.Sort(fileList(tmp))
	files := fileList(tmp).testfiles()

	if !reflect.DeepEqual(files, testdata) {
		t.Errorf("Walk returned unexpected data\nExpected: %v\nActual: %v", testdata, files)
	}
}
コード例 #7
0
ファイル: tabletconntest.go プロジェクト: payintel/vitess
func testSplitQueryPanics(t *testing.T, conn tabletconn.TabletConn) {
	t.Log("testSplitQueryPanics")
	ctx := context.Background()
	if _, err := conn.SplitQuery(ctx, splitQueryBoundQuery, splitQuerySplitColumn, splitQuerySplitCount); err == nil || !strings.Contains(err.Error(), "caught test panic") {
		t.Fatalf("unexpected panic error: %v", err)
	}
}
コード例 #8
0
ファイル: tabletconntest.go プロジェクト: payintel/vitess
func testStreamExecute2Error(t *testing.T, conn tabletconn.TabletConn, fake *FakeQueryService) {
	t.Log("testStreamExecute2Error")
	ctx := context.Background()
	stream, errFunc, err := conn.StreamExecute2(ctx, streamExecuteQuery, streamExecuteBindVars, streamExecuteTransactionID)
	if err != nil {
		t.Fatalf("StreamExecute2 failed: %v", err)
	}
	qr, ok := <-stream
	if !ok {
		t.Fatalf("StreamExecute2 failed: cannot read result1")
	}
	if len(qr.Rows) == 0 {
		qr.Rows = nil
	}
	if !reflect.DeepEqual(*qr, streamExecuteQueryResult1) {
		t.Errorf("Unexpected result1 from StreamExecute2: got %v wanted %v", qr, streamExecuteQueryResult1)
	}
	// signal to the server that the first result has been received
	close(fake.errorWait)
	// After 1 result, we expect to get an error (no more results).
	qr, ok = <-stream
	if ok {
		t.Fatalf("StreamExecute2 channel wasn't closed")
	}
	err = errFunc()
	verifyError(t, err, "StreamExecute2")
}
コード例 #9
0
ファイル: conf_test.go プロジェクト: Elenw/MineGate-Go
func TestPortRange(t *testing.T) {
	defer func() {
		if r := recover(); r != nil {
			t.Fatalf("Recovered from panic: %s", r)
			return
		}
	}()
	defer os.Remove("port_range.yml")
	log.SetLogLevel(log.FATAL)
	if err := ioutil.WriteFile("port_range.yml", []byte(
		`
listen: '1:25565'
upstreams:
- hostname: server.local
  upstream: localhost:65537
- hostname: server2.local
  upstream: localhost:-1`), 0644); err != nil {
		t.Fatal("Unable to write to port_range.yml")
		return
	}
	SetConfig("port_range.yml")
	confInit()
	if len(config.Upstream) != 0 {
		t.Fatalf("No valid upstreams provided, but %d upstreams found!", len(config.Upstream))
		return
	}
	t.Log("Ok, no valid upstream.")
}
コード例 #10
0
ファイル: main_test.go プロジェクト: mscherer/deb-simple
func TestCreateDirs(t *testing.T) {
	pwd, err := os.Getwd()
	if err != nil {
		t.Errorf("Unable to get current working directory: %s", err)
	}
	config := Conf{ListenPort: "9666", RootRepoPath: pwd + "/testing", SupportArch: []string{"cats", "dogs"}, EnableSSL: false}
	// sanity check...
	if config.RootRepoPath != pwd+"/testing" {
		t.Errorf("RootRepoPath is %s, should be %s\n ", config.RootRepoPath, pwd+"/testing")
	}
	t.Log("creating temp dirs in ", config.RootRepoPath)
	dirSuccess := createDirs(config)
	if err := dirSuccess; err != nil {
		t.Errorf("createDirs() failed ")
	}
	for _, archDir := range config.SupportArch {
		if _, err := os.Stat(config.RootRepoPath + "/dists/stable/main/binary-" + archDir); err != nil {
			if os.IsNotExist(err) {
				t.Errorf("Directory for %s does not exist", archDir)
			}
		}
	}

	// cleanup
	if err := os.RemoveAll(config.RootRepoPath); err != nil {
		t.Errorf("error cleaning up after createDirs(): %s", err)
	}
}
コード例 #11
0
ファイル: state_test.go プロジェクト: ailispaw/docker
func TestStateTimeoutWait(t *testing.T) {
	s := NewState()
	started := make(chan struct{})
	go func() {
		s.WaitRunning(100 * time.Millisecond)
		close(started)
	}()
	select {
	case <-time.After(200 * time.Millisecond):
		t.Fatal("Start callback doesn't fire in 100 milliseconds")
	case <-started:
		t.Log("Start callback fired")
	}

	s.Lock()
	s.SetRunning(49, false)
	s.Unlock()

	stopped := make(chan struct{})
	go func() {
		s.WaitRunning(100 * time.Millisecond)
		close(stopped)
	}()
	select {
	case <-time.After(200 * time.Millisecond):
		t.Fatal("Start callback doesn't fire in 100 milliseconds")
	case <-stopped:
		t.Log("Start callback fired")
	}

}
コード例 #12
0
ファイル: api_test.go プロジェクト: glycerine/llgo
func TestIssue8518(t *testing.T) {
	fset := token.NewFileSet()
	conf := Config{
		Packages: make(map[string]*Package),
		Error:    func(err error) { t.Log(err) }, // don't exit after first error
		Import: func(imports map[string]*Package, path string) (*Package, error) {
			return imports[path], nil
		},
	}
	makePkg := func(path, src string) {
		f, err := parser.ParseFile(fset, path, src, 0)
		if err != nil {
			t.Fatal(err)
		}
		pkg, _ := conf.Check(path, fset, []*ast.File{f}, nil) // errors logged via conf.Error
		conf.Packages[path] = pkg
	}

	const libSrc = `
package a 
import "missing"
const C1 = foo
const C2 = missing.C
`

	const mainSrc = `
package main
import "a"
var _ = a.C1
var _ = a.C2
`

	makePkg("a", libSrc)
	makePkg("main", mainSrc) // don't crash when type-checking this package
}
コード例 #13
0
ファイル: config_test.go プロジェクト: zhanglei/bfs
func TestConfig(t *testing.T) {
	var (
		c    *Config
		err  error
		file = "./test/store.yaml"
	)
	t.Log("NewConfig()")
	if c, err = NewConfig(file); err != nil {
		t.Errorf("NewConfig(\"%s\") error(%v)", file, err)
		t.FailNow()
	}
	if c.Index != "/tmp/hijohn.idx" {
		t.FailNow()
	}
	if c.Stat != "localhost:6061" {
		t.FailNow()
	}
	if !c.Pprof.Enable {
		t.FailNow()
	}
	if c.Pprof.Addr != "localhost:6060" {
		t.FailNow()
	}
	if len(c.ZK) != 2 || c.ZK[0] != "1" || c.ZK[1] != "2" {
		t.FailNow()
	}
}
コード例 #14
0
ファイル: callcost_test.go プロジェクト: eloycoto/cgrates
func TestMultipleResultMerge(t *testing.T) {
	t1 := time.Date(2012, time.February, 2, 17, 59, 0, 0, time.UTC)
	t2 := time.Date(2012, time.February, 2, 18, 0, 0, 0, time.UTC)
	cd := &CallDescriptor{Direction: utils.OUT, Category: "0", Tenant: "vdf", Subject: "rif", Destination: "0256", TimeStart: t1, TimeEnd: t2}
	cc1, _ := cd.getCost()
	if cc1.Cost != 61 {
		//ils.LogFull(cc1)
		t.Errorf("expected 61 was %v", cc1.Cost)
		for _, ts := range cc1.Timespans {
			t.Log(ts.RateInterval)
		}
	}
	t1 = time.Date(2012, time.February, 2, 18, 00, 0, 0, time.UTC)
	t2 = time.Date(2012, time.February, 2, 18, 01, 0, 0, time.UTC)
	cd = &CallDescriptor{Direction: utils.OUT, Category: "0", Tenant: "vdf", Subject: "rif", Destination: "0256", TimeStart: t1, TimeEnd: t2}
	cc2, _ := cd.getCost()
	if cc2.Cost != 30 {
		t.Errorf("expected 30 was %v", cc2.Cost)
		for _, ts := range cc1.Timespans {
			t.Log(ts.RateInterval)
		}
	}
	cc1.Merge(cc2)
	if len(cc1.Timespans) != 2 || cc1.Timespans[0].GetDuration().Seconds() != 60 {
		t.Error("wrong resulted timespans: ", len(cc1.Timespans))
	}
	if cc1.Cost != 91 {
		t.Errorf("Exdpected 91 was %v", cc1.Cost)
	}
}
コード例 #15
0
ファイル: operators_test.go プロジェクト: akiross/gogp
func TestPartitionLeaves(t *testing.T) {
	zero, one, id := Terminal1(Constant1(0)), Terminal1(Constant1(1)), Terminal1(Identity1)
	sum, abs, sub := Functional2(Sum), Functional1(Abs), Functional2(Sub)
	var tZero, tOne, tId *Node = mt(zero), mt(one), mt(id) //mt(sum, mt(one), mt(abs, mt(sub, mt(zero), mt(id))))

	t1 := mt(sum, mt(abs, tId), mt(sub, tZero, tOne))

	nods, _, _ := t1.Enumerate()

	le, nonle := partitionLeaves(nods)

	t.Log("Leaves:", le)
	t.Log("Non-leaves:", nonle)

	for i := range le {
		j := le[i]
		if len(nods[j].children) != 0 {
			t.Error("Leaf expected, but had child(ren)", j, nods[j], nods[j].children)
		}
	}
	for i := range nonle {
		j := nonle[i]
		if len(nods[j].children) == 0 {
			t.Error("Non-leaf expected, but didn't have child(ren)", i, j, nods[j])
		}
	}
}
コード例 #16
0
ファイル: tabletconntest.go プロジェクト: payintel/vitess
func testRollback2Panics(t *testing.T, conn tabletconn.TabletConn) {
	t.Log("testRollback2Panics")
	ctx := context.Background()
	if err := conn.Rollback2(ctx, rollbackTransactionID); err == nil || !strings.Contains(err.Error(), "caught test panic") {
		t.Fatalf("unexpected panic error: %v", err)
	}
}
コード例 #17
0
ファイル: tabletconntest.go プロジェクト: payintel/vitess
func testStreamExecute(t *testing.T, conn tabletconn.TabletConn) {
	t.Log("testStreamExecute")
	ctx := context.Background()
	stream, errFunc, err := conn.StreamExecute(ctx, streamExecuteQuery, streamExecuteBindVars, streamExecuteTransactionID)
	if err != nil {
		t.Fatalf("StreamExecute failed: %v", err)
	}
	qr, ok := <-stream
	if !ok {
		t.Fatalf("StreamExecute failed: cannot read result1")
	}
	if len(qr.Rows) == 0 {
		qr.Rows = nil
	}
	if !reflect.DeepEqual(*qr, streamExecuteQueryResult1) {
		t.Errorf("Unexpected result1 from StreamExecute: got %v wanted %v", qr, streamExecuteQueryResult1)
	}
	qr, ok = <-stream
	if !ok {
		t.Fatalf("StreamExecute failed: cannot read result2")
	}
	if len(qr.Fields) == 0 {
		qr.Fields = nil
	}
	if !reflect.DeepEqual(*qr, streamExecuteQueryResult2) {
		t.Errorf("Unexpected result2 from StreamExecute: got %v wanted %v", qr, streamExecuteQueryResult2)
	}
	qr, ok = <-stream
	if ok {
		t.Fatalf("StreamExecute channel wasn't closed")
	}
	if err := errFunc(); err != nil {
		t.Fatalf("StreamExecute errFunc failed: %v", err)
	}
}
コード例 #18
0
ファイル: gcimporter_test.go プロジェクト: rgmabs19357/gcc
func testDir(t *testing.T, dir string, endTime time.Time) (nimports int) {
	dirname := filepath.Join(runtime.GOROOT(), "pkg", runtime.GOOS+"_"+runtime.GOARCH, dir)
	list, err := ioutil.ReadDir(dirname)
	if err != nil {
		t.Errorf("testDir(%s): %s", dirname, err)
	}
	for _, f := range list {
		if time.Now().After(endTime) {
			t.Log("testing time used up")
			return
		}
		switch {
		case !f.IsDir():
			// try extensions
			for _, ext := range pkgExts {
				if strings.HasSuffix(f.Name(), ext) {
					name := f.Name()[0 : len(f.Name())-len(ext)] // remove extension
					if testPath(t, filepath.Join(dir, name)) {
						nimports++
					}
				}
			}
		case f.IsDir():
			nimports += testDir(t, filepath.Join(dir, f.Name()), endTime)
		}
	}
	return
}
コード例 #19
0
ファイル: tabletconntest.go プロジェクト: payintel/vitess
func testExecuteBatch2Panics(t *testing.T, conn tabletconn.TabletConn) {
	t.Log("testExecuteBatch2Panics")
	ctx := context.Background()
	if _, err := conn.ExecuteBatch2(ctx, executeBatchQueries, true, executeBatchTransactionID); err == nil || !strings.Contains(err.Error(), "caught test panic") {
		t.Fatalf("unexpected panic error: %v", err)
	}
}
コード例 #20
0
ファイル: swarm_test.go プロジェクト: rht/bssim
func TestFilterBounds(t *testing.T) {
	ctx := context.Background()
	swarms := makeSwarms(ctx, t, 2)

	conns := make(chan struct{}, 8)
	swarms[0].SetConnHandler(func(conn *Conn) {
		conns <- struct{}{}
	})

	// Address that we wont be dialing from
	_, block, err := net.ParseCIDR("192.0.0.1/8")
	if err != nil {
		t.Fatal(err)
	}

	// set filter on both sides, shouldnt matter
	swarms[1].Filters.AddDialFilter(block)
	swarms[0].Filters.AddDialFilter(block)

	connectSwarms(t, ctx, swarms)

	select {
	case <-time.After(time.Second):
		t.Fatal("should have gotten connection")
	case <-conns:
		t.Log("got connect")
	}
}
コード例 #21
0
ファイル: accessors_test.go プロジェクト: Kunde21/numgo
func TestShape(t *testing.T) {
	var a *Array64
	for i := 0; i < 20; i++ {
		sz := rnd()
		a = NewArray64(nil, sz...)
		for i, v := range a.Shape() {
			if a.shape[i] != v {
				t.Log("Change at", i, "was", a.shape[i], "is", v)
				t.Fail()
			}
		}
		ch := rand.Intn(len(sz))
		sh := a.Shape()
		sh[ch]--
		for i, v := range a.shape {
			if sh[i] != v && i != ch {
				t.Log("Change at", i, "was", a.shape[i], "is", v)
				t.Fail()
			}
			if sh[i] == v && i == ch {
				t.Log("Change propagated at", i, "was", a.shape[i], "is", v)
				t.Fail()
			}
		}
	}
	sh := a.Reshape(-1).Shape()
	if !a.HasErr() || sh != nil {
		t.Log("Shape() error handling incorrect")
		t.Log("Shape:", sh, "Err:", a.getErr())
		t.Fail()
	}
}
コード例 #22
0
ファイル: deserialize_test.go プロジェクト: endocode/ignition
func TestDeserializeFail(t *testing.T) {
	tests := [][]byte{
		// malformed section header
		[]byte(`[Unit
Description=Foo
`),

		// garbage following section header
		[]byte(`[Unit] pants
Description=Foo
`),

		// option without value
		[]byte(`[Unit]
Description
`),

		// garbage inside of section
		[]byte(`[Unit]
<<<<<<
Description=Foo
`),
	}

	for i, tt := range tests {
		output, err := Deserialize(bytes.NewReader(tt))
		if err == nil {
			t.Errorf("case %d: unexpected non-nil error, received nil", i)
			t.Log("Output:")
			logUnitOptionSlice(t, output)
		}
	}
}
コード例 #23
0
ファイル: list_test.go プロジェクト: Mooxe000/GoDash
func Test_Remove_Sync(t *testing.T) {
	FuncName := "GdLists.Remove() AND GdLists.Sync()"

	ssgl, _ := getGdListIns()
	Pssgl := &ssgl
	Pssgl.New()

	v := Pssgl.Remove(2)

	l := Pssgl.Len()
	a := len(Pssgl.Value)
	b := Pssgl.list.Len()
	// dd(l)
	// dd(a)
	// dd(b)

	if l != b || a-b != 1 {
		t.Error(FuncName + " ... failed!")
	}

	v.Sync()

	ls := Pssgl.Len()
	as := len(Pssgl.Value)
	// bs := Pssgl.list.Len()
	// dd(ls)
	// dd(as)
	// dd(bs)

	if as != ls || ls != 4 || Pssgl.Getter(2) != "4" {
		t.Error(FuncName + " ... failed!")
	}

	t.Log(FuncName + " ... ok!")
}
コード例 #24
0
func TestDockerCommandBuildCancel(t *testing.T) {
	if helpers.SkipIntegrationTests(t, "docker", "info") {
		return
	}

	build := &common.Build{
		GetBuildResponse: common.LongRunningBuild,
		Runner: &common.RunnerConfig{
			RunnerSettings: common.RunnerSettings{
				Executor: "docker",
				Docker: &common.DockerConfig{
					Image: "alpine",
				},
			},
		},
	}

	trace := &common.Trace{Writer: os.Stdout, Abort: make(chan interface{}, 1)}

	abortTimer := time.AfterFunc(time.Second, func() {
		t.Log("Interrupt")
		trace.Abort <- true
	})
	defer abortTimer.Stop()

	timeoutTimer := time.AfterFunc(time.Minute, func() {
		t.Log("Timedout")
		t.FailNow()
	})
	defer timeoutTimer.Stop()

	err := build.Run(&common.Config{}, trace)
	assert.IsType(t, err, &common.BuildError{})
	assert.EqualError(t, err, "canceled")
}
コード例 #25
0
ファイル: list_test.go プロジェクト: Mooxe000/GoDash
func Test_Slice(t *testing.T) {
	FuncName := "GdLists.Slice()"

	ssgl, _ := getGdListIns()
	Pssgl := &ssgl
	Pssgl.New()

	// -- a == b == 0
	// s, e, _ := 0, 0, 5       // 1

	// -- a == b == l - 1
	// s, e = 4, 4              // 5
	// -- a == 0 && b == l - 1
	// s, e = 0, 4              // 1, 2, 3, 4, 5
	// -- 0 < a < b < l
	// s, e = 1, 3              // 2, 3, 4
	// a = 0
	// s, e = 0, 2              // 1, 2, 3
	// b = l - 1
	// s, e = 2, 4              // 3, 4, 5

	// v := Pssgl.Slice(s, e)

	// dd(v.Value)

	t.Log(FuncName + " ... ok!")
}
コード例 #26
0
func TestDockerCommandBuildAbort(t *testing.T) {
	if helpers.SkipIntegrationTests(t, "docker", "info") {
		return
	}

	build := &common.Build{
		GetBuildResponse: common.LongRunningBuild,
		Runner: &common.RunnerConfig{
			RunnerSettings: common.RunnerSettings{
				Executor: "docker",
				Docker: &common.DockerConfig{
					Image: "alpine",
				},
			},
		},
		SystemInterrupt: make(chan os.Signal, 1),
	}

	abortTimer := time.AfterFunc(time.Second, func() {
		t.Log("Interrupt")
		build.SystemInterrupt <- os.Interrupt
	})
	defer abortTimer.Stop()

	timeoutTimer := time.AfterFunc(time.Minute, func() {
		t.Log("Timedout")
		t.FailNow()
	})
	defer timeoutTimer.Stop()

	err := build.Run(&common.Config{}, &common.Trace{Writer: os.Stdout})
	assert.EqualError(t, err, "aborted: interrupt")
}
コード例 #27
0
ファイル: list_test.go プロジェクト: Mooxe000/GoDash
func Test_InsertList(t *testing.T) {
	FuncName := "GdLists.InsertList()"

	ssgl, iigl := getGdListIns()
	Pssgl := &ssgl
	Piigl := &iigl
	Pssgl.New()
	Piigl.New()

	// Pssgl.InsertList(2, Piigl)

	// var nssgl GdList
	// nssmi := GdInterface{[]string{"a", "b", "c", "d", "e"}}
	// nssgl.Value = nssmi.ToInterfaces()
	// Pnssgl := (&nssgl).New()

	// Pssgl.InsertList(0, Pnssgl)
	// Pssgl.InsertList(2, Pnssgl)
	// Pssgl.InsertList(4, Pnssgl)
	// Pssgl.InsertList(5, Pnssgl)

	// dd(Pssgl.Sync().Value)

	t.Log(FuncName + " ... ok!")
}
コード例 #28
0
ファイル: tabletconntest.go プロジェクト: payintel/vitess
func testStreamHealth(t *testing.T, conn tabletconn.TabletConn) {
	t.Log("testStreamHealth")
	streamHealthSynchronization = make(chan struct{})
	ctx := context.Background()

	c, errFunc, err := conn.StreamHealth(ctx)
	if err != nil {
		t.Fatalf("StreamHealth failed: %v", err)
	}
	// channel should have one response, then closed
	shr, ok := <-c
	if !ok {
		t.Fatalf("StreamHealth got no response")
	}

	if !reflect.DeepEqual(*shr, *testStreamHealthStreamHealthResponse) {
		t.Errorf("invalid StreamHealthResponse: got %v expected %v", *shr, *testStreamHealthStreamHealthResponse)
	}

	// close streamHealthSynchronization so server side knows we
	// got the response, and it can send the error
	close(streamHealthSynchronization)

	_, ok = <-c
	if ok {
		t.Fatalf("StreamHealth wasn't closed")
	}
	err = errFunc()
	if !strings.Contains(err.Error(), testStreamHealthError) {
		t.Fatalf("StreamHealth failed with the wrong error: %v", err)
	}
}
コード例 #29
0
ファイル: tabletconntest.go プロジェクト: payintel/vitess
func testBegin2Panics(t *testing.T, conn tabletconn.TabletConn) {
	t.Log("testBegin2Panics")
	ctx := context.Background()
	if _, err := conn.Begin2(ctx); err == nil || !strings.Contains(err.Error(), "caught test panic") {
		t.Fatalf("unexpected panic error: %v", err)
	}
}
コード例 #30
0
ファイル: chunkserver_test.go プロジェクト: ule-lab/speedy
func TestReportChunkserverInfoHandler(t *testing.T) {
	param := make(map[string]interface{})
	param["GroupId"] = 1
	param["Ip"] = "127.0.0.1"
	param["Port"] = 6666
	param["TotalFreeSpace"] = 22234
	param["MaxFreeSpace"] = 23233
	param["PendingWrites"] = 10
	param["WritingCount"] = 12
	param["DataDir"] = "/export"
	param["ReadingCount"] = 1
	param["TotalChunks"] = 8
	param["ConnectionsCount"] = 4

	json, err := util.EncodeJson(param)
	if err != nil {
		t.Error(err)
	}

	respData, respCode, err := util.Call("POST", HTTP_SERVER_HOST, "/v1/chunkserver/reportinfo", bytes.NewBuffer(json), nil)
	if err != nil || respCode != http.StatusOK {
		t.Errorf("TestReportChunkserverInfoHandler error: %v, respCode: %d", err, respCode)
	}
	t.Log("reportChunkserverInfo success, respData: %v", respData)
}