File tree Expand file tree Collapse file tree 2 files changed +42
-0
lines changed
Expand file tree Collapse file tree 2 files changed +42
-0
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ func init() {
2020}
2121
2222func (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}
Original file line number Diff line number Diff line change 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\n echo 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+ }
You can’t perform that action at this time.
0 commit comments