当前位置: 首页>>代码示例>>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;未经允许,请勿转载。