From 3a1909f8f4c0f04ecca2118ff532622ad977f868 Mon Sep 17 00:00:00 2001 From: Jerry Yan <792602257@qq.com> Date: Wed, 10 Jun 2026 17:57:48 +0800 Subject: [PATCH] test(git): add parseRemoteBranches unit test --- internal/infra/git/branch_test.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 internal/infra/git/branch_test.go diff --git a/internal/infra/git/branch_test.go b/internal/infra/git/branch_test.go new file mode 100644 index 0000000..5c08695 --- /dev/null +++ b/internal/infra/git/branch_test.go @@ -0,0 +1,23 @@ +package git + +import ( + "testing" + + "github.com/stretchr/testify/require" +) + +func TestParseRemoteBranches(t *testing.T) { + t.Parallel() + input := []byte("aabbccdd\trefs/heads/main\n" + + "eeff0011\trefs/heads/develop\n" + + "22334455\trefs/heads/feature/foo\n" + + "deadbeef\trefs/tags/v1.0\n") + got := parseRemoteBranches(input) + require.Equal(t, []string{"main", "develop", "feature/foo"}, got) +} + +func TestParseRemoteBranches_Empty(t *testing.T) { + t.Parallel() + got := parseRemoteBranches(nil) + require.Nil(t, got) +}