From 0d9451e92cea6312a95626a340ce341f6037a64b3d5adfa8b6f852ba225d72cf Mon Sep 17 00:00:00 2001 From: Adam Majer Date: Mon, 4 Nov 2024 15:12:55 +0100 Subject: [PATCH] {wip} - unit tests `git submodule status` will display current state, which will be overwritten by checkout submodule. Solution is to `submodule deinit` before looking at submodule status. --- workflow-pr/go.mod | 2 +- workflow-pr/main_test.go | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/workflow-pr/go.mod b/workflow-pr/go.mod index 10a1897..5c56700 100644 --- a/workflow-pr/go.mod +++ b/workflow-pr/go.mod @@ -1,6 +1,6 @@ module src.opensuse.org/workflow-pr -go 1.22.3 +go 1.23.2 replace src.opensuse.org/autogits/common => ../bots-common diff --git a/workflow-pr/main_test.go b/workflow-pr/main_test.go index 143e76d..b061d62 100644 --- a/workflow-pr/main_test.go +++ b/workflow-pr/main_test.go @@ -102,6 +102,7 @@ func setupGitForTests(t *testing.T, git *common.GitHandler) { {"prj", "submodule", "add", filepath.Join(git.GitPath, "foo"), "testRepo"}, {"prj", "add", ".gitmodules", "testRepo"}, {"prj", "commit", "-m", "First instance"}, + {"prj", "submodule", "deinit", "testRepo"}, {"", "clone", "prj", common.DefaultGitPrj}, {LocalCMD, "foo", "/usr/bin/touch", "file2"}, {"foo", "add", "file2"}, @@ -139,6 +140,7 @@ func TestUpdatePrBranch(t *testing.T) { t.Error(err) } + git.GitExecOrPanic("prj", "reset", "--hard", "testing") rev := strings.TrimSpace(git.GitExecWithOutputOrPanic(filepath.Join(common.DefaultGitPrj, "testRepo"), "rev-list", "-1", "HEAD")) if rev != req.Pull_Request.Head.Sha { t.Error("prj/testRepo not updated to", req.Pull_Request.Head.Sha, "but is at", rev) @@ -187,6 +189,7 @@ func TestCreatePrBranch(t *testing.T) { if rev != req.Pull_Request.Head.Sha { t.Error("prj/testRepo not updated to", req.Pull_Request.Head.Sha, "but is at", rev) t.Error(buf.String()) + // os.CopyFS("/tmp/test", os.DirFS(git.GitPath)) } }