當前位置: 首頁>>代碼示例>>Golang>>正文


Golang ut.AssertEqual函數代碼示例

本文整理匯總了Golang中github.com/maruel/pre-commit-go/Godeps/_workspace/src/github.com/maruel/ut.AssertEqual函數的典型用法代碼示例。如果您正苦於以下問題:Golang AssertEqual函數的具體用法?Golang AssertEqual怎麽用?Golang AssertEqual使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了AssertEqual函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: TestRound

func TestRound(t *testing.T) {
	t.Parallel()
	ut.AssertEqual(t, 1500*time.Millisecond, round(1549*time.Millisecond, 100*time.Millisecond))
	ut.AssertEqual(t, 1600*time.Millisecond, round(1550*time.Millisecond, 100*time.Millisecond))
	ut.AssertEqual(t, -1500*time.Millisecond, round(-1549*time.Millisecond, 100*time.Millisecond))
	ut.AssertEqual(t, -1600*time.Millisecond, round(-1550*time.Millisecond, 100*time.Millisecond))
}
開發者ID:nodirt,項目名稱:pre-commit-go,代碼行數:7,代碼來源:utils_test.go

示例2: TestConfigYAMLBadMode

func TestConfigYAMLBadMode(t *testing.T) {
	data, err := yaml.Marshal("foo")
	ut.AssertEqual(t, nil, err)
	v := PreCommit
	ut.AssertEqual(t, errors.New("invalid mode \"foo\""), yaml.Unmarshal(data, &v))
	ut.AssertEqual(t, PreCommit, v)
}
開發者ID:nodirt,項目名稱:pre-commit-go,代碼行數:7,代碼來源:config_test.go

示例3: TestChangIgnore

func TestChangIgnore(t *testing.T) {
	t.Parallel()
	c := newChange(&dummyRepo{t, "<root>"}, nil, nil, IgnorePatterns{"*.pb.go"})
	ut.AssertEqual(t, false, c.IsIgnored("foo.go"))
	ut.AssertEqual(t, true, c.IsIgnored("foo.pb.go"))
	ut.AssertEqual(t, true, c.IsIgnored("bar/foo.pb.go"))
}
開發者ID:nodirt,項目名稱:pre-commit-go,代碼行數:7,代碼來源:change_test.go

示例4: setup

func setup(t *testing.T, tmpDir string) {
	_, code, err := internal.Capture(tmpDir, nil, "git", "init")
	ut.AssertEqual(t, 0, code)
	ut.AssertEqual(t, nil, err)
	run(t, tmpDir, nil, "config", "user.email", "[email protected]")
	run(t, tmpDir, nil, "config", "user.name", "nobody")
}
開發者ID:nodirt,項目名稱:pre-commit-go,代碼行數:7,代碼來源:repo_test.go

示例5: TestConfigYAML

func TestConfigYAML(t *testing.T) {
	config := New("0.1")
	data, err := yaml.Marshal(config)
	ut.AssertEqual(t, nil, err)
	actual := &Config{}
	ut.AssertEqual(t, nil, yaml.Unmarshal(data, actual))
	ut.AssertEqual(t, config, actual)
}
開發者ID:nodirt,項目名稱:pre-commit-go,代碼行數:8,代碼來源:config_test.go

示例6: TestGetRepoNoRepo

func TestGetRepoNoRepo(t *testing.T) {
	t.Parallel()
	tmpDir, err := ioutil.TempDir("", "pre-commit-go")
	defer func() {
		if err := internal.RemoveAll(tmpDir); err != nil {
			t.Errorf("%s", err)
		}
	}()

	r, err := GetRepo(tmpDir, "")
	ut.AssertEqual(t, errors.New("failed to find git checkout root"), err)
	ut.AssertEqual(t, nil, r)
}
開發者ID:nodirt,項目名稱:pre-commit-go,代碼行數:13,代碼來源:repo_test.go

示例7: TestCoveragePrerequisites

func TestCoveragePrerequisites(t *testing.T) {
	// This test can't be parallel.
	if !IsContinuousIntegration() {
		old := os.Getenv("CI")
		defer func() {
			ut.ExpectEqual(t, nil, os.Setenv("CI", old))
		}()
		ut.AssertEqual(t, nil, os.Setenv("CI", "true"))
		ut.AssertEqual(t, true, IsContinuousIntegration())
	}
	c := Coverage{UseCoveralls: true}
	ut.AssertEqual(t, 1, len(c.GetPrerequisites()))
}
開發者ID:nodirt,項目名稱:pre-commit-go,代碼行數:13,代碼來源:coverage_test.go

示例8: run

func run(t *testing.T, tmpDir string, env []string, args ...string) string {
	internal := &git{root: tmpDir}
	out, code, err := internal.captureEnv(env, args...)
	ut.AssertEqualf(t, 0, code, "%s", out)
	ut.AssertEqual(t, nil, err)
	return out
}
開發者ID:nodirt,項目名稱:pre-commit-go,代碼行數:7,代碼來源:repo_test.go

示例9: assertHEAD

func assertHEAD(t *testing.T, r ReadOnlyRepo, expected Commit) Commit {
	if head := r.Eval(string(Head)); head != expected {
		t.Logf("%s", strings.Join(os.Environ(), "\n"))
		t.Logf("%s", run(t, r.Root(), nil, "log", "-p", "--format=fuller"))
		ut.AssertEqual(t, expected, head)
	}
	return expected
}
開發者ID:nodirt,項目名稱:pre-commit-go,代碼行數:8,代碼來源:repo_test.go

示例10: TestChecksDescriptions

func TestChecksDescriptions(t *testing.T) {
	t.Parallel()
	for _, name := range getKnownChecks() {
		c := KnownChecks[name]()
		ut.AssertEqual(t, true, c.GetDescription() != "")
		c.GetPrerequisites()
	}
}
開發者ID:Hanxueying,項目名稱:pre-commit-go,代碼行數:8,代碼來源:checks_test.go

示例11: TestCustom

func TestCustom(t *testing.T) {
	t.Parallel()
	p := []CheckPrerequisite{
		{
			HelpCommand:      []string{"go", "version"},
			ExpectedExitCode: 0,
			URL:              "example.com.local",
		},
	}
	c := &Custom{
		Description:   "foo",
		Command:       []string{"go", "version"},
		Prerequisites: p,
	}
	ut.AssertEqual(t, "foo", c.GetDescription())
	ut.AssertEqual(t, p, c.GetPrerequisites())
}
開發者ID:Hanxueying,項目名稱:pre-commit-go,代碼行數:17,代碼來源:checks_test.go

示例12: TestRemoveAllMissing

func TestRemoveAllMissing(t *testing.T) {
	td, err := ioutil.TempDir("", "pre-commit-go")
	ut.ExpectEqual(t, nil, err)

	foo := filepath.Join(td, "foo")
	err = ioutil.WriteFile(foo, []byte("yo"), 0600)
	ut.ExpectEqual(t, nil, err)
	ut.AssertEqual(t, nil, RemoveAll(td))
}
開發者ID:nodirt,項目名稱:pre-commit-go,代碼行數:9,代碼來源:path_test.go

示例13: TestRangeToString

func TestRangeToString(t *testing.T) {
	t.Parallel()
	ut.AssertEqual(t, "", rangeToString(nil))
	ut.AssertEqual(t, "1", rangeToString([]int{1}))
	ut.AssertEqual(t, "1-2", rangeToString([]int{1, 2}))
	ut.AssertEqual(t, "1-3", rangeToString([]int{1, 2, 3}))
	ut.AssertEqual(t, "1,3-4,6-8", rangeToString([]int{1, 3, 4, 6, 7, 8}))
	ut.AssertEqual(t, "1,3-4,6", rangeToString([]int{1, 3, 4, 6}))
}
開發者ID:nodirt,項目名稱:pre-commit-go,代碼行數:9,代碼來源:coverage_test.go

示例14: TestChecksSuccess

func TestChecksSuccess(t *testing.T) {
	// Runs all checks, they should all pass.
	t.Parallel()
	if testing.Short() {
		t.SkipNow()
	}
	td, err := ioutil.TempDir("", "pre-commit-go")
	ut.AssertEqual(t, nil, err)
	defer func() {
		if err := internal.RemoveAll(td); err != nil {
			t.Fail()
		}
	}()
	change := setup(t, td, goodFiles)
	for _, name := range getKnownChecks() {
		c := KnownChecks[name]()
		switch name {
		case "custom":
			c = &Custom{
				Description:   "foo",
				Command:       []string{"go", "version"},
				CheckExitCode: true,
				Prerequisites: []CheckPrerequisite{
					{
						HelpCommand:      []string{"go", "version"},
						ExpectedExitCode: 0,
						URL:              "example.com.local",
					},
				},
			}
		case "copyright":
			cop := c.(*Copyright)
			cop.Header = "// Foo"
		case "coverage":
			cov := c.(*Coverage)
			cov.Global.MinCoverage = 100
			cov.Global.MaxCoverage = 100
			cov.PerDirDefault.MinCoverage = 100
			cov.PerDirDefault.MaxCoverage = 100
		}
		if l, ok := c.(sync.Locker); ok {
			l.Lock()
			l.Unlock()
		}
		if err := c.Run(change, &Options{MaxDuration: 1}); err != nil {
			t.Errorf("%s failed: %s", c.GetName(), err)
		}
	}
}
開發者ID:Hanxueying,項目名稱:pre-commit-go,代碼行數:49,代碼來源:checks_test.go

示例15: setup

func setup(t *testing.T, td string, files map[string]string) scm.Change {
	fooDir := filepath.Join(td, "src", "foo")
	ut.AssertEqual(t, nil, os.MkdirAll(fooDir, 0700))
	for f, c := range files {
		p := filepath.Join(fooDir, f)
		ut.AssertEqual(t, nil, os.MkdirAll(filepath.Dir(p), 0700))
		ut.AssertEqual(t, nil, ioutil.WriteFile(p, []byte(c), 0600))
	}
	_, code, err := internal.Capture(fooDir, nil, "git", "init")
	ut.AssertEqual(t, 0, code)
	ut.AssertEqual(t, nil, err)
	// It's important to add the files to the index, otherwise they will be
	// ignored.
	_, code, err = internal.Capture(fooDir, nil, "git", "add", ".")
	ut.AssertEqual(t, 0, code)
	ut.AssertEqual(t, nil, err)

	repo, err := scm.GetRepo(fooDir, td)
	ut.AssertEqual(t, nil, err)
	change, err := repo.Between(scm.Current, scm.GitInitialCommit, nil)
	ut.AssertEqual(t, nil, err)
	ut.AssertEqual(t, true, change != nil)
	return change
}
開發者ID:Hanxueying,項目名稱:pre-commit-go,代碼行數:24,代碼來源:checks_test.go


注:本文中的github.com/maruel/pre-commit-go/Godeps/_workspace/src/github.com/maruel/ut.AssertEqual函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。