• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang assert.Equal函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: TestNew

func TestNew(t *testing.T) {
	tmpDir, err := ioutil.TempDir("", "tmpdir")
	if err != nil {
		t.Fatalf("error creating temp directory (%s)", err)
	}

	defer func() {
		if err := os.RemoveAll(tmpDir); err != nil {
			t.Fatalf("failed to remove builder-key from %s (%s)", tmpDir, err)
		}
	}()

	builderconf.BuilderKeyLocation = filepath.Join(tmpDir, "builder-key")
	data := []byte("testbuilderkey")
	if err := ioutil.WriteFile(builderconf.BuilderKeyLocation, data, 0644); err != nil {
		t.Fatalf("error creating %s (%s)", builderconf.BuilderKeyLocation, err)
	}

	host := "127.0.0.1"
	port := "80"
	cli, err := New(host, port)
	assert.NoErr(t, err)
	assert.Equal(t, cli.ControllerURL.String(), fmt.Sprintf("http://%s:%s/", host, port), "data")
	assert.Equal(t, cli.HooksToken, string(data), "data")
	assert.Equal(t, cli.UserAgent, "deis-builder", "user-agent")

	port = "invalid-port-number"
	if _, err = New(host, port); err == nil {
		t.Errorf("expected error with invalid port number, got nil")
	}
}
开发者ID:bacongobbler,项目名称:builder,代码行数:31,代码来源:utils_test.go


示例2: TestParseJSONCluster

func TestParseJSONCluster(t *testing.T) {
	const name = "component"
	const description = "test component"
	const version = "1.0.0"
	raw := []byte(fmt.Sprintf(`{
	  "id": "%s",
	  "components": [
	    {
	      "component": {
	        "name": "%s",
	        "description": "%s"
	      },
	      "version": {
	        "version": "%s"
	      }
	    }
	  ]
	}`, mockClusterID, name, description, version))
	cluster, err := ParseJSONCluster(raw)
	assert.NoErr(t, err)

	assert.Equal(t, cluster.ID, mockClusterID, "ID value")
	assert.Equal(t, cluster.Components[0].Component.Name, name, "Name value")
	assert.Equal(t, *cluster.Components[0].Component.Description, description, "Description value")
	assert.Equal(t, cluster.Components[0].Version.Version, version, "Version value")
}
开发者ID:deis,项目名称:workflow-manager,代码行数:26,代码来源:data_test.go


示例3: TestWarn

func TestWarn(t *testing.T) {
	stdout, out, stderr, err := getWriters()
	lg := NewLogger(stdout, stderr, false)
	lg.Warn("hello %s", world)
	assert.Equal(t, string(err.Bytes()), addColor(WarnPrefix+" ", Yellow), "stderr output")
	assert.Equal(t, string(out.Bytes()), "hello world\n", "stdout output")
}
开发者ID:deis,项目名称:pkg,代码行数:7,代码来源:log_test.go


示例4: TestMsgs

func TestMsgs(t *testing.T) {
	const numSends = 20
	srv := StartServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		w.WriteHeader(http.StatusOK)
	}))
	defer srv.Close()
	ch := make(chan []*ReceivedRequest)
	waitTime := 10 * time.Millisecond

	for i := 0; i < numSends; i++ {
		resp, err := http.Get(srv.URLStr())
		assert.NoErr(t, err)
		assert.Equal(t, http.StatusOK, resp.StatusCode, "status code")
	}

	go func() {
		ch <- srv.AcceptN(numSends, waitTime)
	}()
	select {
	case r := <-ch:
		assert.Equal(t, len(r), numSends, "number of recevied messages")
	case <-time.After(recvWaitTime):
		t.Errorf("AcceptN didn't return after [%+v]", recvWaitTime)
	}
}
开发者ID:arschles,项目名称:testsrv,代码行数:25,代码来源:server_test.go


示例5: TestGetComponents

func TestGetComponents(t *testing.T) {
	const componentRoute = "/components"
	resp, apiServer, err := testGet(componentRoute)
	if apiServer != nil {
		apiServer.Close()
	}
	assert.NoErr(t, err)
	assert200(t, resp)
	respData, err := ioutil.ReadAll(resp.Body)
	assert.NoErr(t, err)
	cluster, err := data.ParseJSONCluster(respData)
	assert.NoErr(t, err)
	mockData, err := mocks.GetMockCluster()
	assert.NoErr(t, err)
	mockCluster, err := data.ParseJSONCluster(mockData)
	assert.NoErr(t, err)
	assert.Equal(t, cluster.ID, mockCluster.ID, "cluster ID value")
	for i, component := range cluster.Components {
		assert.Equal(t, component.Component, mockCluster.Components[i].Component, "component type")
		assert.Equal(t, component.Version, mockCluster.Components[i].Version, "version type")
		_, err := mocks.GetMockLatest(component.Component.Name)
		assert.NoErr(t, err)
		// TODO add tests for UpdateAvailable field
	}
}
开发者ID:deis,项目名称:workflow-manager,代码行数:25,代码来源:boot_test.go


示例6: TestGetInstalled

func TestGetInstalled(t *testing.T) {
	cluster, err := GetInstalled(mockInstalledComponents{})
	assert.NoErr(t, err)
	assert.Equal(t, cluster.Components[0].Component.Name, mockComponentName, "Name value")
	assert.Equal(t, *cluster.Components[0].Component.Description, mockComponentDescription, "Description value")
	assert.Equal(t, cluster.Components[0].Version.Version, mockComponentVersion, "Version value")
}
开发者ID:deis,项目名称:workflow-manager,代码行数:7,代码来源:data_test.go


示例7: TestGetID

// Calls GetID twice, the first time we expect our passed-in struct w/ Get() method
// to be invoked, the 2nd time we expect to receive the same value back (cached in memory)
// and for the passed-in Get() method to be ignored
func TestGetID(t *testing.T) {
	cid := &testClusterID{}
	id, err := GetID(cid)
	assert.NoErr(t, err)
	assert.Equal(t, id, mockClusterID, "cluster ID value")
	cid.cache = "something else"
	id, err = GetID(cid)
	assert.NoErr(t, err)
	assert.Equal(t, id, "something else", "cluster ID value")
}
开发者ID:deis,项目名称:workflow-manager,代码行数:13,代码来源:data_test.go


示例8: 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


示例9: TestDebug

func TestDebug(t *testing.T) {
	stdout, out, stderr, err := getWriters()
	lgOn := NewLogger(stdout, stderr, true)
	lgOff := NewLogger(stdout, stderr, false)
	lgOff.Debug("hello %s", world)
	assert.Equal(t, out.Len(), 0, "stdout buffer length")
	assert.Equal(t, err.Len(), 0, "stderr buffer length")
	lgOn.Debug("hello %s", world)
	assert.Equal(t, string(err.Bytes()), addColor(DebugPrefix+" ", Cyan), "stderr output")
	assert.Equal(t, string(out.Bytes()), "hello world\n", "stdout output")
}
开发者ID:deis,项目名称:pkg,代码行数:11,代码来源:log_test.go


示例10: TestControllerFromDeisRemote

func TestControllerFromDeisRemote(t *testing.T) {
	t.Parallel()

	url, err := url.Parse("ssh://[email protected]:2222/api.coderunner.git")
	assert.Equal(t, nil, err, "controller-from-deis-remote")

	expected := "https://services.alea.dev"
	actual := controllerFromDeisRemote(url)

	assert.Equal(t, expected, actual, "controller-from-deis-remote")
}
开发者ID:Codaisseur,项目名称:deis-backing-services,代码行数:11,代码来源:app_test.go


示例11: TestGetAvailableVersions

// Calls GetAvailableVersions twice, the first time we expect our passed-in struct w/ Refresh() method
// to be invoked, the 2nd time we expect to receive the same value back (cached in memory)
// and for the passed-in Refresh() method to be ignored
func TestGetAvailableVersions(t *testing.T) {
	mock := getMockComponentVersions()
	var mockVersions []models.ComponentVersion
	assert.NoErr(t, json.Unmarshal(mock, &mockVersions))
	versions, err := GetAvailableVersions(testAvailableVersions{}, models.Cluster{})
	assert.NoErr(t, err)
	assert.Equal(t, versions, mockVersions, "component versions data")
	versions, err = GetAvailableVersions(shouldBypassAvailableVersions{}, models.Cluster{})
	assert.NoErr(t, err)
	assert.Equal(t, versions, mockVersions, "component versions data")
}
开发者ID:deis,项目名称:workflow-manager,代码行数:14,代码来源:available_versions_test.go


示例12: TestReadinessControllerGetErr

func TestReadinessControllerGetErr(t *testing.T) {
	nsLister := emptyNamespaceLister{}
	client := errGetClient{err: errTest}

	h := readinessHandler(client, nsLister)
	w := httptest.NewRecorder()
	r, err := http.NewRequest("GET", "/readiness", bytes.NewBuffer(nil))
	assert.NoErr(t, err)
	h.ServeHTTP(w, r)
	assert.Equal(t, w.Code, http.StatusServiceUnavailable, "response code")
	assert.Equal(t, w.Body.Len(), 0, "response body length")
}
开发者ID:aledbf,项目名称:builder,代码行数:12,代码来源:healthz_handler_test.go


示例13: TestHealthZCircuitOpen

func TestHealthZCircuitOpen(t *testing.T) {
	bLister := emptyBucketLister{}
	c := sshd.NewCircuit()

	h := healthZHandler(bLister, c)
	w := httptest.NewRecorder()
	r, err := http.NewRequest("GET", "/healthz", bytes.NewBuffer(nil))
	assert.NoErr(t, err)
	h.ServeHTTP(w, r)
	assert.Equal(t, w.Code, http.StatusServiceUnavailable, "response code")
	assert.Equal(t, w.Body.Len(), 0, "response body length")
}
开发者ID:bacongobbler,项目名称:builder,代码行数:12,代码来源:healthz_handler_test.go


示例14: TestGetRegistryDetailsGCRSuccess

func TestGetRegistryDetailsGCRSuccess(t *testing.T) {
	encToken := base64.StdEncoding.EncodeToString([]byte("testuser:testpassword"))
	auth := []byte(`
    {
    "auths": {
              "https://test.io": {
                  "auth": "` + encToken + `",
                  "email": "[email protected]"
              }
          }
    }
`)
	configData := make(map[string][]byte)
	configData[api.DockerConfigJsonKey] = auth
	configSecret := api.Secret{Data: configData}
	configGetter := &k8s.FakeSecret{
		FnGet: func(string) (*api.Secret, error) {
			return &configSecret, nil
		},
	}

	srvAccount := []byte(`
		{
		"project_id": "deis-test"
	}
		`)
	data := map[string][]byte{"key.json": srvAccount}
	secret := api.Secret{Data: data}
	getter := &k8s.FakeSecret{
		FnGet: func(string) (*api.Secret, error) {
			return &secret, nil
		},
	}

	kubeClient := &k8s.FakeSecretsNamespacer{
		Fn: func(namespace string) client.SecretsInterface {
			if namespace == "deis" {
				return getter
			}
			return configGetter
		},
	}

	expectedData := map[string]string{"DEIS_REGISTRY_USERNAME": "testuser", "DEIS_REGISTRY_PASSWORD": "testpassword", "DEIS_REGISTRY_HOSTNAME": "https://test.io", "DEIS_REGISTRY_GCS_PROJ_ID": "deis-test"}
	expectedImage := "test.io/deis-test/test-image"

	image := "test-image"
	regDetails, err := getRegistryDetails(kubeClient, &image, "gcr", deisNamespace, "private-registry")

	assert.NoErr(t, err)
	assert.Equal(t, expectedData, regDetails, "registry details")
	assert.Equal(t, expectedImage, image, "image")
}
开发者ID:mboersma,项目名称:builder,代码行数:53,代码来源:registry_test.go


示例15: TestAppFromDeisRemote

func TestAppFromDeisRemote(t *testing.T) {
	t.Parallel()

	url, err := url.Parse("ssh://[email protected]:2222/api.coderunner.git")
	assert.Equal(t, nil, err, "app-from-deis-remote")

	expected := "api.coderunner"
	actual, err := appFromDeisRemote(url)

	assert.Equal(t, expected, actual, "app-from-deis-remote")
	assert.Equal(t, nil, err, "app-from-deis-remote")
}
开发者ID:Codaisseur,项目名称:deis-backing-services,代码行数:12,代码来源:app_test.go


示例16: TestWritePlainText

func TestWritePlainText(t *testing.T) {
	const text = "foo"
	handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		writePlainText(text, w)
	})
	resp, err := getTestHandlerResponse(handler)
	assert.NoErr(t, err)
	assert.Equal(t, resp.Header.Get("Content-Type"), "text/plain", "Content-Type value")
	respData, err := ioutil.ReadAll(resp.Body)
	assert.NoErr(t, err)
	assert.Equal(t, string(respData), text, "text response")
}
开发者ID:deis,项目名称:workflow-manager,代码行数:12,代码来源:handlers_test.go


示例17: 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


示例18: TestHealthZSuccess

func TestHealthZSuccess(t *testing.T) {
	nsLister := emptyNamespaceLister{}
	bLister := emptyBucketLister{}
	c := sshd.NewCircuit()
	c.Close()

	h := healthZHandler(nsLister, bLister, c)
	w := httptest.NewRecorder()
	r, err := http.NewRequest("GET", "/healthz", bytes.NewBuffer(nil))
	assert.NoErr(t, err)
	h.ServeHTTP(w, r)
	assert.Equal(t, w.Code, http.StatusOK, "response code")
	assert.Equal(t, w.Body.Len(), 0, "response body length")
}
开发者ID:vdice,项目名称:builder,代码行数:14,代码来源:healthz_handler_test.go


示例19: TestNotLocked

func TestNotLocked(t *testing.T) {
	mut := new(sync.Mutex)
	lockID := NewLockID()
	router := mux.NewRouter()
	registerLockHandler(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")
	assert.Equal(t, string(w.Body.Bytes()), lockID.id, "lock ID")
}
开发者ID:bacongobbler,项目名称:riak,代码行数:14,代码来源:lock_handler_test.go


示例20: TestReadinessNamespaceListErr

func TestReadinessNamespaceListErr(t *testing.T) {
	nsLister := errNamespaceLister{err: errTest}
	client := successGetClient{}
	os.Setenv("DEIS_CONTROLLER_SERVICE_HOST", "127.0.0.1")
	os.Setenv("DEIS_CONTROLLER_SERVICE_PORT", "8000")

	h := readinessHandler(client, nsLister)
	w := httptest.NewRecorder()
	r, err := http.NewRequest("GET", "/readiness", bytes.NewBuffer(nil))
	assert.NoErr(t, err)
	h.ServeHTTP(w, r)
	assert.Equal(t, w.Code, http.StatusServiceUnavailable, "response code")
	assert.Equal(t, w.Body.Len(), 0, "response body length")
}
开发者ID:aledbf,项目名称:builder,代码行数:14,代码来源:healthz_handler_test.go



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang assert.NoErr函数代码示例发布时间:2022-05-24
下一篇:
Golang circbuf.NewBuffer函数代码示例发布时间:2022-05-24
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap