| 1 | using GitMcp.Core; |
| 2 | |
| 3 | namespace GitMcp.Tests; |
| 4 | |
| 5 | public sealed class GitCommandBuilderTests |
| 6 | { |
| 7 | [Fact] |
| 8 | public void StatusShortBranch_matches_three_tokens() |
| 9 | { |
| 10 | var a = GitCommandBuilder.StatusShortBranch(); |
| 11 | Assert.Equal(["status", "--short", "--branch"], a); |
| 12 | } |
| 13 | |
| 14 | [Fact] |
| 15 | public void Push_mcp_defaults_origin_when_empty_remote() |
| 16 | { |
| 17 | var mcp = GitCommandBuilder.Push(null, null, defaultOriginWhenRemoteEmpty: true); |
| 18 | Assert.Equal(["push", "origin"], mcp); |
| 19 | var ide = GitCommandBuilder.Push(null, null, defaultOriginWhenRemoteEmpty: false); |
| 20 | Assert.Equal(["push"], ide); |
| 21 | } |
| 22 | |
| 23 | [Fact] |
| 24 | public void Fetch_rejects_remote_with_all() |
| 25 | { |
| 26 | var r = GitCommandBuilder.Fetch(all: true, prune: true, remote: "origin"); |
| 27 | Assert.False(r.IsSuccess); |
| 28 | Assert.Contains("all=true", r.Error, StringComparison.Ordinal); |
| 29 | } |
| 30 | |
| 31 | [Fact] |
| 32 | public void Pull_rejects_mismatched_remote_branch() |
| 33 | { |
| 34 | var r = GitCommandBuilder.Pull("origin", null, ffOnly: true); |
| 35 | Assert.False(r.IsSuccess); |
| 36 | } |
| 37 | |
| 38 | [Fact] |
| 39 | public void Log_clamps_count() |
| 40 | { |
| 41 | var a = GitCommandBuilder.Log(9999); |
| 42 | Assert.Contains(GitCommandBuilder.LogCountMax.ToString(), string.Join(" ", a), StringComparison.Ordinal); |
| 43 | } |
| 44 | } |
| 45 | |