MCPcopy Create free account
hub / github.com/diillson/chatcli / TestGetGitInfo_InRepo

Function TestGetGitInfo_InRepo

utils/git_utils_test.go:30–48  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

28}
29
30func TestGetGitInfo_InRepo(t *testing.T) {
31 mockExec := new(MockCommandExecutor)
32
33 // Configura o mock para simular sucesso em todos os comandos
34 mockExec.On("Run", "git", []string{"rev-parse", "--is-inside-work-tree"}).Return(nil)
35 mockExec.On("Output", "git", []string{"remote", "-v"}).Return([]byte("origin git@github.com:user/repo.git (fetch)"), nil)
36 mockExec.On("Output", "git", []string{"branch", "--show-current"}).Return([]byte("main"), nil)
37 mockExec.On("Output", "git", []string{"status", "-s", "-b"}).Return([]byte("## main...origin/main\nM README.md"), nil)
38 // Configure os outros comandos para retornar saídas vazias para simplificar
39 mockExec.On("Output", "git", mock.Anything).Return([]byte(""), nil)
40
41 info, err := GetGitInfo(mockExec)
42
43 assert.NoError(t, err)
44 assert.Contains(t, info, "Branch Atual: main")
45 assert.Contains(t, info, "Status Resumido:\n## main...origin/main\nM README.md")
46
47 mockExec.AssertExpectations(t)
48}
49
50func TestGetGitInfo_NotInRepo(t *testing.T) {
51 mockExec := new(MockCommandExecutor)

Callers

nothing calls this directly

Calls 1

GetGitInfoFunction · 0.85

Tested by

no test coverage detected