当前位置: 首页>>代码示例>>Golang>>正文


Golang assert.True函数代码示例

本文整理汇总了Golang中github.com/arschles/assert.True函数的典型用法代码示例。如果您正苦于以下问题:Golang True函数的具体用法?Golang True怎么用?Golang True使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了True函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: TestRunningK8sDataDaemonsets

func TestRunningK8sDataDaemonsets(t *testing.T) {
	c := getK8sClientForDaemonSets(t)
	deisK8sResources := NewResourceInterfaceNamespaced(c, namespace)
	runningK8sData := NewRunningK8sData(deisK8sResources)
	daemonsets, err := runningK8sData.DaemonSets()
	assert.NoErr(t, err)
	assert.True(t, len(daemonsets) == 2, "daemonsets response slice was not the expected length")
	assert.True(t, daemonsets[0].Data != daemonsets[1].Data, "daemonsets should not be identical")
}
开发者ID:deis,项目名称:workflow-manager,代码行数:9,代码来源:k8s_test.go

示例2: TestRunningK8sDataNodes

func TestRunningK8sDataNodes(t *testing.T) {
	c := getK8sClientForNodes(t)
	deisK8sResources := NewResourceInterfaceNamespaced(c, namespace)
	runningK8sData := NewRunningK8sData(deisK8sResources)
	nodes, err := runningK8sData.Nodes()
	assert.NoErr(t, err)
	assert.True(t, len(nodes) == 3, "nodes response slice was not the expected length")
	assert.True(t, nodes[0].Data != nodes[1].Data, "nodes should not be identical")
}
开发者ID:deis,项目名称:workflow-manager,代码行数:9,代码来源:k8s_test.go

示例3: TestRunningK8sDataPods

func TestRunningK8sDataPods(t *testing.T) {
	c := getK8sClientForPods(t)
	deisK8sResources := NewResourceInterfaceNamespaced(c, namespace)
	runningK8sData := NewRunningK8sData(deisK8sResources)
	pods, err := runningK8sData.Pods()
	assert.NoErr(t, err)
	assert.True(t, len(pods) == 2, "pods response slice was not the expected length")
	assert.True(t, pods[0].Data != pods[1].Data, "pods should not be identical")
}
开发者ID:deis,项目名称:workflow-manager,代码行数:9,代码来源:k8s_test.go

示例4: TestRunningK8sDataReplicationControllers

func TestRunningK8sDataReplicationControllers(t *testing.T) {
	c := getK8sClientForReplicationControllers(t)
	deisK8sResources := NewResourceInterfaceNamespaced(c, namespace)
	runningK8sData := NewRunningK8sData(deisK8sResources)
	rcs, err := runningK8sData.ReplicationControllers()
	assert.NoErr(t, err)
	assert.True(t, len(rcs) == 2, "rc response slice was not the expected length")
	assert.True(t, rcs[0].Data != rcs[1].Data, "rcs should not be identical")
}
开发者ID:deis,项目名称:workflow-manager,代码行数:9,代码来源:k8s_test.go

示例5: TestRunningK8sDataServices

func TestRunningK8sDataServices(t *testing.T) {
	c := getK8sClientForServices(t)
	//_, _ = c.Setup(t).Services(namespace).List(api.ListOptions{})
	deisK8sResources := NewResourceInterfaceNamespaced(c, namespace)
	runningK8sData := NewRunningK8sData(deisK8sResources)
	services, err := runningK8sData.Services()
	assert.NoErr(t, err)
	assert.True(t, len(services) == 2, "services response slice was not the expected length")
	assert.True(t, services[0].Data != services[1].Data, "services should not be identical")
}
开发者ID:deis,项目名称:workflow-manager,代码行数:10,代码来源:k8s_test.go

示例6: TestDoPeriodic

func TestDoPeriodic(t *testing.T) {
	interval := time.Duration(3000) * time.Millisecond
	p := &testPeriodic{t: t, err: nil, freq: interval}
	closeCh1 := DoPeriodic([]Periodic{p})
	time.Sleep(interval / 2) // wait a little while for the goroutine to call the job once
	assert.True(t, p.i == 1, "the periodic wasn't called once")
	time.Sleep(interval)
	assert.True(t, p.i == 2, "the periodic wasn't called twice")
	time.Sleep(interval)
	assert.True(t, p.i == 3, "the periodic wasn't called thrice")
	close(closeCh1)
}
开发者ID:deis,项目名称:workflow-manager,代码行数:12,代码来源:jobs_test.go

示例7: TestWaitForObjectMissing

func TestWaitForObjectMissing(t *testing.T) {
	statter := &FakeObjectStatter{
		Fn: func(context.Context, string) (storagedriver.FileInfo, error) {
			return storagedriver.FileInfoInternal{FileInfoFields: storagedriver.FileInfoFields{}}, storagedriver.PathNotFoundError{Path: objPath}
		},
	}
	err := WaitForObject(statter, objPath, 1*time.Millisecond, 2*time.Millisecond)
	assert.True(t, err != nil, "no error received when there should have been")
	// it should make 1 call immediately, then calls at 1ms and 2ms
	assert.True(
		t,
		len(statter.Calls) >= 1,
		"the statter was not called, but should have been called at least once",
	)
}
开发者ID:bacongobbler,项目名称:builder,代码行数:15,代码来源:object_test.go

示例8: TestParse

func TestParse(t *testing.T) {
	//TODO: use gogenerate to generate valid html templates
	//http://godoc.org/github.com/arschles/gogenerate

	tmpl := `
    <html>
      <head>
        <title>hello {{.name}}</title>
      </head>
      <body>
        {{.greeting}}
      </body>
    </html>
  `
	fileName := "mytmpl.tmpl"
	tmplBytes := []byte(tmpl)
	expectedErr := errors.New("template not found")
	assetFunc := createValidAssetFunc(fileName, tmplBytes, expectedErr)

	tmpl1, err1 := New("test", assetFunc).Parse(fileName)
	assert.NoErr(t, err1)
	assert.False(t, tmpl1 == nil, "tmpl1 was nil when it should not have been")
	tmpl2, err2 := New("test1", assetFunc).Parse(fileName + fileName)
	assert.Err(t, err2, expectedErr)
	assert.True(t, tmpl2 == nil, "tmpl2 was not nil when it should have been")

	//TODO: check actual template output
	name := "Aaron"
	tmplData := map[string]string{
		"name": name,
	}
	buf1 := bytes.NewBuffer([]byte{})
	executeErr1 := tmpl1.Execute(buf1, tmplData)
	stdTmpl, stdTmplParseErr := template.New("referenceTest").Parse(tmpl)
	assert.NoErr(t, stdTmplParseErr)
	buf2 := bytes.NewBuffer([]byte{})
	executeErr2 := stdTmpl.Execute(buf2, tmplData)

	assert.NoErr(t, executeErr1)
	assert.NoErr(t, executeErr2)

	bytes1 := buf1.Bytes()
	bytes2 := buf2.Bytes()

	assert.True(t,
		string(bytes1) == string(bytes2),
		"actual template output %s is not equal expected %s", string(bytes1), string(bytes2))
}
开发者ID:topscore,项目名称:sup,代码行数:48,代码来源:template_test.go

示例9: TestCollectEnv

func TestCollectEnv(t *testing.T) {
	envMap := collectEnv()
	pwd, ok := envMap["PWD"]
	assert.True(t, ok, "'PWD' not found in the env")
	wd, err := os.Getwd()
	assert.NoErr(t, err)
	assert.Equal(t, pwd, wd, "working dir")
}
开发者ID:arschles,项目名称:envtpl,代码行数:8,代码来源:env_test.go

示例10: TestGitPktLine

func TestGitPktLine(t *testing.T) {
	b := new(bytes.Buffer)
	str := "hello world"
	err := gitPktLine(b, str)
	assert.NoErr(t, err)
	outStr := string(b.Bytes())
	assert.True(t, len(outStr) > 4, "output string <= 4 chars")
	assert.Equal(t, outStr[:4], fmt.Sprintf("%04x", len(str)+4), "hex prefix")
	assert.Equal(t, outStr[4:], str, "remainder of string")
}
开发者ID:aledbf,项目名称:builder,代码行数:10,代码来源:server_test.go

示例11: TestGetProcFileFromServerFailure

func TestGetProcFileFromServerFailure(t *testing.T) {
	expectedErr := errors.New("test error")
	getter := &storage.FakeObjectGetter{
		Fn: func(context.Context, string) ([]byte, error) {
			return []byte("web: example-go"), expectedErr
		},
	}

	_, err := getProcFile(getter, "", objKey, buildTypeProcfile)
	assert.Err(t, err, fmt.Errorf("error in reading %s (%s)", objKey, expectedErr))
	assert.True(t, err != nil, "no error received when there should have been")
}
开发者ID:bacongobbler,项目名称:builder,代码行数:12,代码来源:build_test.go

示例12: TestSuccessfulRoundTrip

func TestSuccessfulRoundTrip(t *testing.T) {
	mut := new(sync.Mutex)
	lockID := NewLockID()
	router := mux.NewRouter()
	registerLockHandler(router, mut, lockID)
	registerUnlockHandler(router, mut, lockID)

	w := httptest.NewRecorder()
	r, err := http.NewRequest("POST", "/lock", bytes.NewReader(nil))
	assert.NoErr(t, err)
	router.ServeHTTP(w, r)
	assert.Equal(t, w.Code, http.StatusOK, "response code")
	idStr := string(w.Body.Bytes())
	assert.True(t, len(idStr) > 0, "returned lock ID was empty")
	assert.True(t, lockID.Equals(idStr), fmt.Sprintf("internal lock ID (%s) was not equal returned lock ID (%s)", lockID.id, idStr))

	w = httptest.NewRecorder()
	r, err = http.NewRequest("DELETE", "/lock/"+idStr, bytes.NewReader(nil))
	assert.NoErr(t, err)
	router.ServeHTTP(w, r)
	assert.Equal(t, w.Code, http.StatusOK, "response code")
}
开发者ID:bacongobbler,项目名称:riak,代码行数:22,代码来源:round_trip_test.go

示例13: TestObjectExistsSuccess

func TestObjectExistsSuccess(t *testing.T) {
	objInfo := storagedriver.FileInfoInternal{storagedriver.FileInfoFields{Path: objPath, Size: 1234}}
	statter := &FakeObjectStatter{
		Fn: func(context.Context, string) (storagedriver.FileInfo, error) {
			return objInfo, nil
		},
	}
	exists, err := ObjectExists(statter, objPath)
	assert.NoErr(t, err)
	assert.True(t, exists, "object not found when it should be present")
	assert.Equal(t, len(statter.Calls), 1, "number of StatObject calls")
	assert.Equal(t, statter.Calls[0].Path, objPath, "object key")
}
开发者ID:aledbf,项目名称:builder,代码行数:13,代码来源:object_test.go

示例14: TestConcurrentPushSameRepo

// TestConcurrentPushSameRepo tests many concurrent pushes, each to the same repo
func TestConcurrentPushSameRepo(t *testing.T) {
	const testingServerAddr = "127.0.0.1:2245"
	key, err := sshTestingHostKey()
	assert.NoErr(t, err)

	cfg, err := serverConfigure()
	assert.NoErr(t, err)
	cfg.AddHostKey(key)

	c := NewCircuit()
	pushLock := NewInMemoryRepositoryLock(500 * time.Millisecond)
	runServer(cfg, c, pushLock, testingServerAddr, 2*time.Second, t)

	// Give server time to initialize.
	time.Sleep(200 * time.Millisecond)

	assert.Equal(t, c.State(), ClosedState, "circuit state")

	// Connect to the server and issue env var set. This should return true.
	client, err := ssh.Dial("tcp", testingServerAddr, clientConfig())
	assert.NoErr(t, err)

	const numPushers = 4
	outCh := make(chan *sshSessionOutput, numPushers)
	for i := 0; i < numPushers; i++ {
		go func() {
			sess, newSessErr := client.NewSession()
			assert.NoErr(t, newSessErr)
			defer sess.Close()
			out, outErr := sess.Output("git-upload-pack /demo.git")
			outCh <- &sshSessionOutput{outStr: string(out), err: outErr}
		}()
	}

	// ensure at least 1 output was successful
	foundOK := false
	to := 1 * time.Second
	for i := 0; i < numPushers; i++ {
		select {
		case sessOut := <-outCh:
			if sessOut.outStr == "OK" {
				foundOK = true
			}
		case <-time.After(to):
			t.Fatalf("didn't receive an output within %s", to)
		}
	}
	assert.True(t, foundOK, "no SSH requests were successful")
}
开发者ID:bacongobbler,项目名称:builder,代码行数:50,代码来源:server_test.go

示例15: TestMultipleSameRepoLocks

func TestMultipleSameRepoLocks(t *testing.T) {
	var wg sync.WaitGroup
	const repo = "repo1"
	const numTries = 100
	lck := NewInMemoryRepositoryLock()
	assert.NoErr(t, lck.Lock(repo, 0*time.Second))
	for i := 0; i < numTries; i++ {
		wg.Add(1)
		go func() {
			defer wg.Done()
			assert.True(t, lck.Lock(repo, 0*time.Second) != nil, "lock of already locked repo should return error")
		}()
	}
	assert.NoErr(t, waitWithTimeout(&wg, 1*time.Second))
	assert.NoErr(t, lck.Unlock(repo, 0*time.Second))
	for i := 0; i < numTries; i++ {
		wg.Add(1)
		go func() {
			defer wg.Done()
			assert.True(t, lck.Unlock(repo, 0*time.Second) != nil, "unlock of already unlocked repo should return error")
		}()
	}
	assert.NoErr(t, waitWithTimeout(&wg, 1*time.Second))
}
开发者ID:aledbf,项目名称:builder,代码行数:24,代码来源:lock_test.go


注:本文中的github.com/arschles/assert.True函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。