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


Golang assert.Equal函数代码示例

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


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

示例1: TestEncodeExtensions

func TestEncodeExtensions(t *testing.T) {
	var buf bytes.Buffer
	exts := []*PointerExtension{
		NewPointerExtension("foo", 0, "foo_oid"),
		NewPointerExtension("bar", 1, "bar_oid"),
		NewPointerExtension("baz", 2, "baz_oid"),
	}
	pointer := NewPointer("main_oid", 12345, exts)
	_, err := EncodePointer(&buf, pointer)
	assert.Equal(t, nil, err)

	bufReader := bufio.NewReader(&buf)
	assertLine(t, bufReader, "version https://git-lfs.github.com/spec/v1\n")
	assertLine(t, bufReader, "ext-0-foo sha256:foo_oid\n")
	assertLine(t, bufReader, "ext-1-bar sha256:bar_oid\n")
	assertLine(t, bufReader, "ext-2-baz sha256:baz_oid\n")
	assertLine(t, bufReader, "oid sha256:main_oid\n")
	assertLine(t, bufReader, "size 12345\n")

	line, err := bufReader.ReadString('\n')
	if err == nil {
		t.Fatalf("More to read: %s", line)
	}
	assert.Equal(t, "EOF", err.Error())
}
开发者ID:ambf1436,项目名称:git-lfs,代码行数:25,代码来源:pointer_test.go

示例2: TestCertFromSSLCAInfoEnv

func TestCertFromSSLCAInfoEnv(t *testing.T) {

	tempfile, err := ioutil.TempFile("", "testcert")
	assert.Equal(t, nil, err, "Error creating temp cert file")
	defer os.Remove(tempfile.Name())

	_, err = tempfile.WriteString(testCert)
	assert.Equal(t, nil, err, "Error writing temp cert file")
	tempfile.Close()

	oldEnv := Config.envVars
	defer func() {
		Config.envVars = oldEnv
	}()

	Config.envVars = map[string]string{"GIT_SSL_CAINFO": tempfile.Name()}

	// Should match any host at all
	pool := getRootCAsForHost("git-lfs.local")
	assert.NotEqual(t, (*x509.CertPool)(nil), pool)
	pool = getRootCAsForHost("wronghost.com")
	assert.NotEqual(t, (*x509.CertPool)(nil), pool)
	pool = getRootCAsForHost("notthisone.com:8888")
	assert.NotEqual(t, (*x509.CertPool)(nil), pool)

}
开发者ID:strich,项目名称:git-lfs,代码行数:26,代码来源:certs_test.go

示例3: TestCertFromSSLCAPathEnv

func TestCertFromSSLCAPathEnv(t *testing.T) {

	tempdir, err := ioutil.TempDir("", "testcertdir")
	assert.Equal(t, nil, err, "Error creating temp cert dir")
	defer os.RemoveAll(tempdir)

	err = ioutil.WriteFile(filepath.Join(tempdir, "cert1.pem"), []byte(testCert), 0644)
	assert.Equal(t, nil, err, "Error creating cert file")

	oldEnv := Config.envVars
	defer func() {
		Config.envVars = oldEnv
	}()

	Config.envVars = map[string]string{"GIT_SSL_CAPATH": tempdir}

	// Should match any host at all
	pool := getRootCAsForHost("git-lfs.local")
	assert.NotEqual(t, (*x509.CertPool)(nil), pool)
	pool = getRootCAsForHost("wronghost.com")
	assert.NotEqual(t, (*x509.CertPool)(nil), pool)
	pool = getRootCAsForHost("notthisone.com:8888")
	assert.NotEqual(t, (*x509.CertPool)(nil), pool)

}
开发者ID:strich,项目名称:git-lfs,代码行数:25,代码来源:certs_test.go

示例4: TestAccessAbsentConfig

func TestAccessAbsentConfig(t *testing.T) {
	config := &Configuration{}
	assert.Equal(t, "none", config.Access("download"))
	assert.Equal(t, "none", config.Access("upload"))
	assert.Equal(t, false, config.PrivateAccess("download"))
	assert.Equal(t, false, config.PrivateAccess("upload"))
}
开发者ID:unitychrism,项目名称:git-lfs,代码行数:7,代码来源:config_test.go

示例5: TestCurrentRefAndCurrentRemoteRef

func TestCurrentRefAndCurrentRemoteRef(t *testing.T) {
	repo := test.NewRepo(t)
	repo.Pushd()
	defer func() {
		repo.Popd()
		repo.Cleanup()
	}()

	// test commits; we'll just modify the same file each time since we're
	// only interested in branches
	inputs := []*test.CommitInput{
		{ // 0
			Files: []*test.FileInput{
				{Filename: "file1.txt", Size: 20},
			},
		},
		{ // 1
			NewBranch: "branch2",
			Files: []*test.FileInput{
				{Filename: "file1.txt", Size: 25},
			},
		},
		{ // 2
			ParentBranches: []string{"master"}, // back on master
			Files: []*test.FileInput{
				{Filename: "file1.txt", Size: 30},
			},
		},
		{ // 3
			NewBranch: "branch3",
			Files: []*test.FileInput{
				{Filename: "file1.txt", Size: 32},
			},
		},
	}
	outputs := repo.AddCommits(inputs)
	// last commit was on branch3
	ref, err := CurrentRef()
	assert.Equal(t, nil, err)
	assert.Equal(t, &Ref{"branch3", RefTypeLocalBranch, outputs[3].Sha}, ref)
	test.RunGitCommand(t, true, "checkout", "master")
	ref, err = CurrentRef()
	assert.Equal(t, nil, err)
	assert.Equal(t, &Ref{"master", RefTypeLocalBranch, outputs[2].Sha}, ref)
	// Check remote
	repo.AddRemote("origin")
	test.RunGitCommand(t, true, "push", "-u", "origin", "master:someremotebranch")
	ref, err = CurrentRemoteRef()
	assert.Equal(t, nil, err)
	assert.Equal(t, &Ref{"origin/someremotebranch", RefTypeRemoteBranch, outputs[2].Sha}, ref)

	refname, err := RemoteRefNameForCurrentBranch()
	assert.Equal(t, nil, err)
	assert.Equal(t, "origin/someremotebranch", refname)

	remote, err := RemoteForCurrentBranch()
	assert.Equal(t, nil, err)
	assert.Equal(t, "origin", remote)
}
开发者ID:rachid1985,项目名称:git-lfs,代码行数:59,代码来源:git_test.go

示例6: TestNtlmHeaderParseValid

func TestNtlmHeaderParseValid(t *testing.T) {
	res := http.Response{}
	res.Header = make(map[string][]string)
	res.Header.Add("Www-Authenticate", "NTLM "+base64.StdEncoding.EncodeToString([]byte("I am a moose")))
	bytes, err := parseChallengeResponse(&res)
	assert.Equal(t, err, nil)
	assert.Equal(t, strings.HasPrefix(string(bytes), "NTLM"), false)
}
开发者ID:ambf1436,项目名称:git-lfs,代码行数:8,代码来源:ntlm_test.go

示例7: TestFetchPruneConfigDefault

func TestFetchPruneConfigDefault(t *testing.T) {
	config := &Configuration{}
	fp := config.FetchPruneConfig()

	assert.Equal(t, 7, fp.FetchRecentRefsDays)
	assert.Equal(t, 0, fp.FetchRecentCommitsDays)
	assert.Equal(t, 3, fp.PruneOffsetDays)
	assert.Equal(t, true, fp.FetchRecentRefsIncludeRemotes)

}
开发者ID:nakaeeee,项目名称:git-lfs,代码行数:10,代码来源:config_test.go

示例8: TestLoadInvalidExtension

func TestLoadInvalidExtension(t *testing.T) {
	config := &Configuration{}

	ext := config.Extensions()["foo"]

	assert.Equal(t, "", ext.Name)
	assert.Equal(t, "", ext.Clean)
	assert.Equal(t, "", ext.Smudge)
	assert.Equal(t, 0, ext.Priority)
}
开发者ID:nakaeeee,项目名称:git-lfs,代码行数:10,代码来源:config_test.go

示例9: TestWriterWithCallback

func TestWriterWithCallback(t *testing.T) {
	called := 0
	calledRead := make([]int64, 0, 2)

	reader := &CallbackReader{
		TotalSize: 5,
		Reader:    bytes.NewBufferString("BOOYA"),
		C: func(total int64, read int64, current int) error {
			called += 1
			calledRead = append(calledRead, read)
			assert.Equal(t, 5, int(total))
			return nil
		},
	}

	readBuf := make([]byte, 3)
	n, err := reader.Read(readBuf)
	assert.Equal(t, nil, err)
	assert.Equal(t, "BOO", string(readBuf[0:n]))

	n, err = reader.Read(readBuf)
	assert.Equal(t, nil, err)
	assert.Equal(t, "YA", string(readBuf[0:n]))

	assert.Equal(t, 2, called)
	assert.Equal(t, 2, len(calledRead))
	assert.Equal(t, 3, int(calledRead[0]))
	assert.Equal(t, 5, int(calledRead[1]))
}
开发者ID:devcurmudgeon,项目名称:git-lfs,代码行数:29,代码来源:util_test.go

示例10: TestSSHGetExeAndArgsSsh

func TestSSHGetExeAndArgsSsh(t *testing.T) {
	endpoint := Config.Endpoint("download")
	endpoint.SshUserAndHost = "[email protected]"
	oldGITSSH := Config.Getenv("GIT_SSH")
	Config.Setenv("GIT_SSH", "")
	exe, args := sshGetExeAndArgs(endpoint)
	assert.Equal(t, "ssh", exe)
	assert.Equal(t, []string{"[email protected]"}, args)

	Config.Setenv("GIT_SSH", oldGITSSH)
}
开发者ID:unitychrism,项目名称:git-lfs,代码行数:11,代码来源:ssh_test.go

示例11: TestBareEndpointAddsLfsSuffix

func TestBareEndpointAddsLfsSuffix(t *testing.T) {
	config := &Configuration{
		gitConfig: map[string]string{"remote.origin.url": "https://example.com/foo/bar.git"},
		remotes:   []string{},
	}

	endpoint := config.Endpoint()
	assert.Equal(t, "https://example.com/foo/bar.git/info/lfs", endpoint.Url)
	assert.Equal(t, "", endpoint.SshUserAndHost)
	assert.Equal(t, "", endpoint.SshPath)
}
开发者ID:nakaeeee,项目名称:git-lfs,代码行数:11,代码来源:config_test.go

示例12: TestEncodeEmpty

func TestEncodeEmpty(t *testing.T) {
	var buf bytes.Buffer
	pointer := NewPointer("", 0, nil)
	_, err := EncodePointer(&buf, pointer)
	assert.Equal(t, nil, err)

	bufReader := bufio.NewReader(&buf)
	val, err := bufReader.ReadString('\n')
	assert.Equal(t, "", val)
	assert.Equal(t, "EOF", err.Error())
}
开发者ID:unitychrism,项目名称:git-lfs,代码行数:11,代码来源:pointer_test.go

示例13: TestEndpointDefaultsToOrigin

func TestEndpointDefaultsToOrigin(t *testing.T) {
	config := &Configuration{
		gitConfig: map[string]string{"remote.origin.lfsurl": "abc"},
		remotes:   []string{},
	}

	endpoint := config.Endpoint()
	assert.Equal(t, "abc", endpoint.Url)
	assert.Equal(t, "", endpoint.SshUserAndHost)
	assert.Equal(t, "", endpoint.SshPath)
}
开发者ID:nakaeeee,项目名称:git-lfs,代码行数:11,代码来源:config_test.go

示例14: TestNtlmCloneRequest

func TestNtlmCloneRequest(t *testing.T) {
	req1, _ := http.NewRequest("Method", "url", nil)
	cloneOfReq1, err := cloneRequest(req1)
	assert.Equal(t, err, nil)
	assertRequestsEqual(t, req1, cloneOfReq1)

	req2, _ := http.NewRequest("Method", "url", bytes.NewReader([]byte("Moose can be request bodies")))
	cloneOfReq2, err := cloneRequest(req2)
	assert.Equal(t, err, nil)
	assertRequestsEqual(t, req2, cloneOfReq2)
}
开发者ID:ambf1436,项目名称:git-lfs,代码行数:11,代码来源:ntlm_test.go

示例15: TestCertVerifyDisabledGlobalEnv

func TestCertVerifyDisabledGlobalEnv(t *testing.T) {

	assert.Equal(t, false, isCertVerificationDisabledForHost("anyhost.com"))

	oldEnv := Config.envVars
	defer func() {
		Config.envVars = oldEnv
	}()
	Config.envVars = map[string]string{"GIT_SSL_NO_VERIFY": "1"}

	assert.Equal(t, true, isCertVerificationDisabledForHost("anyhost.com"))
}
开发者ID:strich,项目名称:git-lfs,代码行数:12,代码来源:certs_test.go


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