infra/go: rearrange packages
created the util package and moved some stuff out of test_util
so that all asserts can live in test_util without circular imports
BUG=None
TEST=run_tests.sh
Change-Id: I8a60554cb6f7a2a6b7f2725b98ccfe4026eb1828
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/infra/go/+/1758853
Reviewed-by: Evan Hernandez <evanhernandez@chromium.org>
Reviewed-by: Benjamin Gordon <bmgordon@chromium.org>
Commit-Queue: Jack Neus <jackneus@google.com>
Tested-by: Jack Neus <jackneus@google.com>
diff --git a/internal/git/git_test.go b/internal/git/git_test.go
index 30b67d5..17f7a98 100644
--- a/internal/git/git_test.go
+++ b/internal/git/git_test.go
@@ -13,7 +13,7 @@
"testing"
"go.chromium.org/chromiumos/infra/go/internal/cmd"
- "go.chromium.org/chromiumos/infra/go/internal/test_util"
+ "go.chromium.org/chromiumos/infra/go/internal/util"
)
func TestRunGit_success(t *testing.T) {
@@ -465,7 +465,7 @@
branches, err := RemoteBranches(local, "remote")
assert.NilError(t, err)
- assert.Assert(t, test_util.UnorderedEqual(branches, []string{"foo", "bar"}))
+ assert.Assert(t, util.UnorderedEqual(branches, []string{"foo", "bar"}))
ok, err := RemoteHasBranch(local, "remote", "foo")
assert.NilError(t, err)
assert.Assert(t, ok)
@@ -473,49 +473,3 @@
assert.NilError(t, err)
assert.Assert(t, !ok)
}
-
-func TestAssertGitBranches_success(t *testing.T) {
- tmpDir, err := ioutil.TempDir("", "assert_git_branches_test")
- assert.NilError(t, err)
- defer os.RemoveAll(tmpDir)
-
- assert.NilError(t, Init(tmpDir, false))
-
- branches := []string{"branch1", "branch2", "branch3", "extra"}
- for _, branch := range branches {
- assert.NilError(t, CreateBranch(tmpDir, branch))
- // Empty commit so that branch is not "unborn".
- _, err := RunGit(tmpDir, []string{"commit", "-m", "init", "--allow-empty"})
- assert.NilError(t, err)
- }
-
- assert.NilError(t, AssertGitBranches(tmpDir, branches[:3]))
-}
-
-func TestAssertGitBranchesExact_success(t *testing.T) {
- tmpDir, err := ioutil.TempDir("", "assert_git_branches_test")
- assert.NilError(t, err)
- defer os.RemoveAll(tmpDir)
-
- assert.NilError(t, Init(tmpDir, false))
-
- branches := []string{"branch1", "branch2", "branch3", "branch4"}
- for _, branch := range branches {
- assert.NilError(t, CreateBranch(tmpDir, branch))
- // Empty commit so that branch is not "unborn".
- _, err := RunGit(tmpDir, []string{"commit", "-m", "init", "--allow-empty"})
- assert.NilError(t, err)
- }
-
- assert.NilError(t, AssertGitBranchesExact(tmpDir, append(branches, "branch2")))
- assert.ErrorContains(t, AssertGitBranchesExact(tmpDir, branches[:3]), "mismatch")
-}
-
-func TestAssertGitBranches_failure(t *testing.T) {
- tmpDir, err := ioutil.TempDir("", "assert_git_branches_test")
- assert.NilError(t, err)
- defer os.RemoveAll(tmpDir)
-
- assert.NilError(t, Init(tmpDir, false))
- assert.ErrorContains(t, AssertGitBranches(tmpDir, []string{"master", "foo"}), "mismatch")
-}