diff options
Diffstat (limited to 'pkg/commands/git_commands/working_tree_test.go')
-rw-r--r-- | pkg/commands/git_commands/working_tree_test.go | 56 |
1 files changed, 0 insertions, 56 deletions
diff --git a/pkg/commands/git_commands/working_tree_test.go b/pkg/commands/git_commands/working_tree_test.go index ca2881efe..6d084bfbe 100644 --- a/pkg/commands/git_commands/working_tree_test.go +++ b/pkg/commands/git_commands/working_tree_test.go @@ -2,8 +2,6 @@ package git_commands import ( "fmt" - "os" - "regexp" "testing" "github.com/go-errors/errors" @@ -430,60 +428,6 @@ func TestWorkingTreeCheckoutFile(t *testing.T) { } } -func TestWorkingTreeApplyPatch(t *testing.T) { - type scenario struct { - testName string - runner *oscommands.FakeCmdObjRunner - test func(error) - } - - expectFn := func(regexStr string, errToReturn error) func(cmdObj oscommands.ICmdObj) (string, error) { - return func(cmdObj oscommands.ICmdObj) (string, error) { - re := regexp.MustCompile(regexStr) - cmdStr := cmdObj.ToString() - matches := re.FindStringSubmatch(cmdStr) - assert.Equal(t, 2, len(matches), fmt.Sprintf("unexpected command: %s", cmdStr)) - - filename := matches[1] - - content, err := os.ReadFile(filename) - assert.NoError(t, err) - - assert.Equal(t, "test", string(content)) - - return "", errToReturn - } - } - - scenarios := []scenario{ - { - testName: "valid case", - runner: oscommands.NewFakeRunner(t). - ExpectFunc(expectFn(`git apply --cached "(.*)"`, nil)), - test: func(err error) { - assert.NoError(t, err) - }, - }, - { - testName: "command returns error", - runner: oscommands.NewFakeRunner(t). - ExpectFunc(expectFn(`git apply --cached "(.*)"`, errors.New("error"))), - test: func(err error) { - assert.Error(t, err) - }, - }, - } - - for _, s := range scenarios { - s := s - t.Run(s.testName, func(t *testing.T) { - instance := buildWorkingTreeCommands(commonDeps{runner: s.runner}) - s.test(instance.ApplyPatch("test", "cached")) - s.runner.CheckForMissingCalls() - }) - } -} - func TestWorkingTreeDiscardUnstagedFileChanges(t *testing.T) { type scenario struct { testName string |