Skip to content

Commit aab0d2c

Browse files
authored
Fix 397 (#405)
Fix 397
2 parents a46d04f + 7d513f3 commit aab0d2c

File tree

5 files changed

+49
-14
lines changed

5 files changed

+49
-14
lines changed

cmd/apply_posix_test.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,6 @@ import (
99
"github.com/twpayne/go-vfs/vfst"
1010
)
1111

12-
type scriptTestCase struct {
13-
name string
14-
root interface{}
15-
data map[string]interface{}
16-
tests []vfst.Test
17-
}
18-
1912
func getApplyScriptTestCases(tempDir string) []scriptTestCase {
2013
return []scriptTestCase{
2114
{

cmd/apply_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@ import (
1313
"github.com/twpayne/go-vfs/vfst"
1414
)
1515

16+
type scriptTestCase struct {
17+
name string
18+
root interface{}
19+
data map[string]interface{}
20+
tests []vfst.Test
21+
}
22+
1623
func TestApplyCommand(t *testing.T) {
1724
for _, tc := range []struct {
1825
name string

cmd/apply_windows_test.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,6 @@ import (
99
"github.com/twpayne/go-vfs/vfst"
1010
)
1111

12-
type scriptTestCase struct {
13-
name string
14-
root interface{}
15-
data map[string]interface{}
16-
tests []vfst.Test
17-
}
18-
1912
func getApplyScriptTestCases(tempDir string) []scriptTestCase {
2013
return []scriptTestCase{
2114
{

cmd/diff.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ func init() {
2020
}
2121

2222
func (c *Config) runDiffCmd(fs vfs.FS, args []string) error {
23+
c.DryRun = true
2324
mutator := chezmoi.NewLoggingMutator(c.Stdout(), chezmoi.NullMutator{}, c.colored)
2425
return c.applyArgs(fs, args, mutator)
2526
}

cmd/diff_posix_test.go

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// +build !windows
2+
3+
package cmd
4+
5+
import (
6+
"io/ioutil"
7+
"os"
8+
"path/filepath"
9+
"testing"
10+
11+
"github.com/stretchr/testify/assert"
12+
"github.com/stretchr/testify/require"
13+
vfs "github.com/twpayne/go-vfs"
14+
"github.com/twpayne/go-vfs/vfst"
15+
)
16+
17+
func TestDiffDoesNotRunScript(t *testing.T) {
18+
tempDir, err := ioutil.TempDir("", "chezmoi")
19+
require.NoError(t, err)
20+
defer func() {
21+
require.NoError(t, os.RemoveAll(tempDir))
22+
}()
23+
fs := vfs.NewPathFS(vfs.OSFS, tempDir)
24+
require.NoError(t, vfst.NewBuilder().Build(
25+
fs,
26+
map[string]interface{}{
27+
"/home/user/.local/share/chezmoi/run_true": "#!/bin/sh\necho foo >>" + filepath.Join(tempDir, "evidence") + "\n",
28+
},
29+
))
30+
c := &Config{
31+
SourceDir: "/home/user/.local/share/chezmoi",
32+
DestDir: "/",
33+
Umask: 022,
34+
}
35+
assert.NoError(t, c.runDiffCmd(fs, nil))
36+
vfst.RunTests(t, vfs.OSFS, "",
37+
vfst.TestPath(filepath.Join(tempDir, "evidence"),
38+
vfst.TestDoesNotExist,
39+
),
40+
)
41+
}

0 commit comments

Comments
 (0)