(t *testing.T)
| 28 | } |
| 29 | |
| 30 | func 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 | |
| 50 | func TestGetGitInfo_NotInRepo(t *testing.T) { |
| 51 | mockExec := new(MockCommandExecutor) |
nothing calls this directly
no test coverage detected