Repository: twpayne/chezmoi
Pull request #31 (2018-11-27 18:53:04)

Use a tagged version of github.com/twpayne/go-vfs


Patch:
diff --git a/go.mod b/go.mod
index dfe7f2e74..932bfd38c 100644
--- a/go.mod
+++ b/go.mod
@@ -11,5 +11,5 @@ require (
 	github.com/spf13/cobra v0.0.3
 	github.com/spf13/viper v1.2.1
 	github.com/stretchr/testify v1.2.2 // indirect
-	github.com/twpayne/go-vfs v0.0.0-20181126231609-c493eb0d7c34
+	github.com/twpayne/go-vfs v0.1.1
 )
diff --git a/go.sum b/go.sum
index 4f7464c0a..a9cf1e212 100644
--- a/go.sum
+++ b/go.sum
@@ -36,8 +36,8 @@ github.com/spf13/viper v1.2.1 h1:bIcUwXqLseLF3BDAZduuNfekWG87ibtFxi59Bq+oI9M=
 github.com/spf13/viper v1.2.1/go.mod h1:P4AexN0a+C9tGAnUFNwDMYYZv3pjFuvmeiMyKRaNVlI=
 github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
 github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
-github.com/twpayne/go-vfs v0.0.0-20181126231609-c493eb0d7c34 h1:kDVvF1P97298JY3yQpZGiQmVnccDLFDLaqTUgCExBrM=
-github.com/twpayne/go-vfs v0.0.0-20181126231609-c493eb0d7c34/go.mod h1:OIXA6zWkcn7Jk46XT7ceYqBMeIkfzJ8WOBhGJM0W4y8=
+github.com/twpayne/go-vfs v0.1.1 h1:5HFYyah2qxr+b2SDlF6ExZScSgjMvAzhjrnwxKLhI34=
+github.com/twpayne/go-vfs v0.1.1/go.mod h1:OIXA6zWkcn7Jk46XT7ceYqBMeIkfzJ8WOBhGJM0W4y8=
 golang.org/x/sys v0.0.0-20180906133057-8cf3aee42992 h1:BH3eQWeGbwRU2+wxxuuPOdFBmaiBH81O8BugSjHeTFg=
 golang.org/x/sys v0.0.0-20180906133057-8cf3aee42992/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
 golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=


Test patch:
diff --git a/cmd/add_test.go b/cmd/add_test.go
index 27a0514bf..81583749d 100644
--- a/cmd/add_test.go
+++ b/cmd/add_test.go
@@ -3,7 +3,7 @@ package cmd
 import (
 	"testing"
 
-	"github.com/twpayne/go-vfs/vfstest"
+	"github.com/twpayne/go-vfs/vfst"
 )
 
 func TestAddCommand(t *testing.T) {
@@ -20,9 +20,9 @@ func TestAddCommand(t *testing.T) {
 			root: map[string]interface{}{
 				"/home/jenkins/.bashrc": "foo",
 			},
-			tests: []vfstest.Test{
-				vfstest.TestPath("/home/jenkins/.chezmoi", vfstest.TestIsDir, vfstest.TestModePerm(0700)),
-				vfstest.TestPath("/home/jenkins/.chezmoi/dot_bashrc", vfstest.TestModeIsRegular, vfstest.TestContentsString("foo")),
+			tests: []vfst.Test{
+				vfst.TestPath("/home/jenkins/.chezmoi", vfst.TestIsDir, vfst.TestModePerm(0700)),
+				vfst.TestPath("/home/jenkins/.chezmoi/dot_bashrc", vfst.TestModeIsRegular, vfst.TestContentsString("foo")),
 			},
 		},
 		{
@@ -32,12 +32,12 @@ func TestAddCommand(t *testing.T) {
 				Template: true,
 			},
 			root: map[string]interface{}{
-				"/home/jenkins":            &vfstest.Dir{Perm: 0755},
-				"/home/jenkins/.chezmoi":   &vfstest.Dir{Perm: 0700},
+				"/home/jenkins":            &vfst.Dir{Perm: 0755},
+				"/home/jenkins/.chezmoi":   &vfst.Dir{Perm: 0700},
 				"/home/jenkins/.gitconfig": "[user]\n\tname = John Smith\n\temail = john.smith@company.com\n",
 			},
-			tests: []vfstest.Test{
-				vfstest.TestPath("/home/jenkins/.chezmoi/dot_gitconfig.tmpl", vfstest.TestModeIsRegular, vfstest.TestContentsString("[user]\n\tname = {{ .name }}\n\temail = {{ .email }}\n")),
+			tests: []vfst.Test{
+				vfst.TestPath("/home/jenkins/.chezmoi/dot_gitconfig.tmpl", vfst.TestModeIsRegular, vfst.TestContentsString("[user]\n\tname = {{ .name }}\n\temail = {{ .email }}\n")),
 			},
 		},
 		{
@@ -47,24 +47,24 @@ func TestAddCommand(t *testing.T) {
 				Recursive: true,
 			},
 			root: map[string]interface{}{
-				"/home/jenkins":                             &vfstest.Dir{Perm: 0755},
-				"/home/jenkins/.chezmoi":                    &vfstest.Dir{Perm: 0700},
+				"/home/jenkins":                             &vfst.Dir{Perm: 0755},
+				"/home/jenkins/.chezmoi":                    &vfst.Dir{Perm: 0700},
 				"/home/jenkins/.config/micro/settings.json": "{}",
 			},
-			tests: []vfstest.Test{
-				vfstest.TestPath("/home/jenkins/.chezmoi/dot_config/micro/settings.json", vfstest.TestModeIsRegular, vfstest.TestContentsString("{}")),
+			tests: []vfst.Test{
+				vfst.TestPath("/home/jenkins/.chezmoi/dot_config/micro/settings.json", vfst.TestModeIsRegular, vfst.TestContentsString("{}")),
 			},
 		},
 		{
 			name: "add_nested_directory",
 			args: []string{"/home/jenkins/.config/micro/settings.json"},
 			root: map[string]interface{}{
-				"/home/jenkins":                             &vfstest.Dir{Perm: 0755},
-				"/home/jenkins/.chezmoi":                    &vfstest.Dir{Perm: 0700},
+				"/home/jenkins":                             &vfst.Dir{Perm: 0755},
+				"/home/jenkins/.chezmoi":                    &vfst.Dir{Perm: 0700},
 				"/home/jenkins/.config/micro/settings.json": "{}",
 			},
-			tests: []vfstest.Test{
-				vfstest.TestPath("/home/jenkins/.chezmoi/dot_config/micro/settings.json", vfstest.TestModeIsRegular, vfstest.TestContentsString("{}")),
+			tests: []vfst.Test{
+				vfst.TestPath("/home/jenkins/.chezmoi/dot_config/micro/settings.json", vfst.TestModeIsRegular, vfst.TestContentsString("{}")),
 			},
 		},
 		{
@@ -74,24 +74,24 @@ func TestAddCommand(t *testing.T) {
 				Empty: true,
 			},
 			root: map[string]interface{}{
-				"/home/jenkins":          &vfstest.Dir{Perm: 0755},
-				"/home/jenkins/.chezmoi": &vfstest.Dir{Perm: 0700},
+				"/home/jenkins":          &vfst.Dir{Perm: 0755},
+				"/home/jenkins/.chezmoi": &vfst.Dir{Perm: 0700},
 				"/home/jenkins/empty":    "",
 			},
-			tests: []vfstest.Test{
-				vfstest.TestPath("/home/jenkins/.chezmoi/empty_empty", vfstest.TestModeIsRegular, vfstest.TestContents(nil)),
+			tests: []vfst.Test{
+				vfst.TestPath("/home/jenkins/.chezmoi/empty_empty", vfst.TestModeIsRegular, vfst.TestContents(nil)),
 			},
 		},
 		{
 			name: "add_symlink",
 			args: []string{"/home/jenkins/foo"},
 			root: map[string]interface{}{
-				"/home/jenkins":          &vfstest.Dir{Perm: 0755},
-				"/home/jenkins/.chezmoi": &vfstest.Dir{Perm: 0700},
-				"/home/jenkins/foo":      &vfstest.Symlink{Target: "bar"},
+				"/home/jenkins":          &vfst.Dir{Perm: 0755},
+				"/home/jenkins/.chezmoi": &vfst.Dir{Perm: 0700},
+				"/home/jenkins/foo":      &vfst.Symlink{Target: "bar"},
 			},
-			tests: []vfstest.Test{
-				vfstest.TestPath("/home/jenkins/.chezmoi/symlink_foo", vfstest.TestModeIsRegular, vfstest.TestContentsString("bar")),
+			tests: []vfst.Test{
+				vfst.TestPath("/home/jenkins/.chezmoi/symlink_foo", vfst.TestModeIsRegular, vfst.TestContentsString("bar")),
 			},
 		},
 		{
@@ -101,27 +101,27 @@ func TestAddCommand(t *testing.T) {
 				Recursive: true,
 			},
 			root: map[string]interface{}{
-				"/home/jenkins":          &vfstest.Dir{Perm: 0755},
-				"/home/jenkins/.chezmoi": &vfstest.Dir{Perm: 0700},
-				"/home/jenkins/foo/bar":  &vfstest.Symlink{Target: "baz"},
+				"/home/jenkins":          &vfst.Dir{Perm: 0755},
+				"/home/jenkins/.chezmoi": &vfst.Dir{Perm: 0700},
+				"/home/jenkins/foo/bar":  &vfst.Symlink{Target: "baz"},
 			},
-			tests: []vfstest.Test{
-				vfstest.TestPath("/home/jenkins/.chezmoi/foo", vfstest.TestIsDir),
-				vfstest.TestPath("/home/jenkins/.chezmoi/foo/symlink_bar", vfstest.TestModeIsRegular, vfstest.TestContentsString("baz")),
+			tests: []vfst.Test{
+				vfst.TestPath("/home/jenkins/.chezmoi/foo", vfst.TestIsDir),
+				vfst.TestPath("/home/jenkins/.chezmoi/foo/symlink_bar", vfst.TestModeIsRegular, vfst.TestContentsString("baz")),
 			},
 		},
 		{
 			name: "add_symlink_with_parent_dir",
 			args: []string{"/home/jenkins/foo/bar/baz"},
 			root: map[string]interface{}{
-				"/home/jenkins":             &vfstest.Dir{Perm: 0755},
-				"/home/jenkins/.chezmoi":    &vfstest.Dir{Perm: 0700},
-				"/home/jenkins/foo/bar/baz": &vfstest.Symlink{Target: "qux"},
+				"/home/jenkins":             &vfst.Dir{Perm: 0755},
+				"/home/jenkins/.chezmoi":    &vfst.Dir{Perm: 0700},
+				"/home/jenkins/foo/bar/baz": &vfst.Symlink{Target: "qux"},
 			},
-			tests: []vfstest.Test{
-				vfstest.TestPath("/home/jenkins/.chezmoi/foo", vfstest.TestIsDir),
-				vfstest.TestPath("/home/jenkins/.chezmoi/foo/bar", vfstest.TestIsDir),
-				vfstest.TestPath("/home/jenkins/.chezmoi/foo/bar/symlink_baz", vfstest.TestModeIsRegular, vfstest.TestContentsString("qux")),
+			tests: []vfst.Test{
+				vfst.TestPath("/home/jenkins/.chezmoi/foo", vfst.TestIsDir),
+				vfst.TestPath("/home/jenkins/.chezmoi/foo/bar", vfst.TestIsDir),
+				vfst.TestPath("/home/jenkins/.chezmoi/foo/bar/symlink_baz", vfst.TestModeIsRegular, vfst.TestContentsString("qux")),
 			},
 		},
 	} {
@@ -139,15 +139,15 @@ func TestAddCommand(t *testing.T) {
 				},
 				Add: tc.addCommandConfig,
 			}
-			fs, cleanup, err := vfstest.NewTempFS(tc.root)
+			fs, cleanup, err := vfst.NewTestFS(tc.root)
 			defer cleanup()
 			if err != nil {
-				t.Fatalf("vfstest.NewTempFS(_) == _, _, %v, want _, _, <nil>", err)
+				t.Fatalf("vfst.NewTestFS(_) == _, _, %v, want _, _, <nil>", err)
 			}
 			if err := c.runAddCommandE(fs, nil, tc.args); err != nil {
 				t.Errorf("c.runAddCommandE(fs, nil, %+v) == %v, want <nil>", tc.args, err)
 			}
-			vfstest.RunTests(t, fs, "", tc.tests)
+			vfst.RunTests(t, fs, "", tc.tests)
 		})
 	}
 }
diff --git a/lib/chezmoi/chezmoi_test.go b/lib/chezmoi/chezmoi_test.go
index 22551bd61..1a336606a 100644
--- a/lib/chezmoi/chezmoi_test.go
+++ b/lib/chezmoi/chezmoi_test.go
@@ -5,7 +5,7 @@ import (
 	"testing"
 
 	"github.com/d4l3k/messagediff"
-	"github.com/twpayne/go-vfs/vfstest"
+	"github.com/twpayne/go-vfs/vfst"
 )
 
 func TestSourceDirName(t *testing.T) {
@@ -368,10 +368,10 @@ func TestTargetStatePopulate(t *testing.T) {
 		},
 	} {
 		t.Run(tc.name, func(t *testing.T) {
-			fs, cleanup, err := vfstest.NewTempFS(tc.root)
+			fs, cleanup, err := vfst.NewTestFS(tc.root)
 			defer cleanup()
 			if err != nil {
-				t.Fatalf("vfstest.NewTempFS(_) == _, _, %v, want _, _, <nil>", err)
+				t.Fatalf("vfst.NewTestFS(_) == _, _, %v, want _, _, <nil>", err)
 			}
 			ts := NewTargetState("/", 0, tc.sourceDir, tc.data)
 			if err := ts.Populate(fs); err != nil {
@@ -398,7 +398,7 @@ func TestEndToEnd(t *testing.T) {
 			name: "all",
 			root: map[string]interface{}{
 				"/home/user/.bashrc":                          "foo",
-				"/home/user/replace_symlink":                  &vfstest.Symlink{Target: "foo"},
+				"/home/user/replace_symlink":                  &vfst.Symlink{Target: "foo"},
 				"/home/user/.chezmoi/dot_bashrc":              "bar",
 				"/home/user/.chezmoi/.git/HEAD":               "HEAD",
 				"/home/user/.chezmoi/dot_hgrc.tmpl":           "[ui]\nusername = {{ .name }} <{{ .email }}>\n",
@@ -414,20 +414,20 @@ func TestEndToEnd(t *testing.T) {
 			},
 			targetDir: "/home/user",
 			umask:     022,
-			tests: []vfstest.Test{
-				vfstest.TestPath("/home/user/.bashrc", vfstest.TestModeIsRegular, vfstest.TestContentsString("bar")),
-				vfstest.TestPath("/home/user/.hgrc", vfstest.TestModeIsRegular, vfstest.TestContentsString("[ui]\nusername = John Smith <hello@example.com>\n")),
-				vfstest.TestPath("/home/user/foo", vfstest.TestModeIsRegular, vfstest.TestContents(nil)),
-				vfstest.TestPath("/home/user/bar", vfstest.TestModeType(os.ModeSymlink), vfstest.TestSymlinkTarget("empty")),
-				vfstest.TestPath("/home/user/replace_symlink", vfstest.TestModeType(os.ModeSymlink), vfstest.TestSymlinkTarget("bar")),
+			tests: []vfst.Test{
+				vfst.TestPath("/home/user/.bashrc", vfst.TestModeIsRegular, vfst.TestContentsString("bar")),
+				vfst.TestPath("/home/user/.hgrc", vfst.TestModeIsRegular, vfst.TestContentsString("[ui]\nusername = John Smith <hello@example.com>\n")),
+				vfst.TestPath("/home/user/foo", vfst.TestModeIsRegular, vfst.TestContents(nil)),
+				vfst.TestPath("/home/user/bar", vfst.TestModeType(os.ModeSymlink), vfst.TestSymlinkTarget("empty")),
+				vfst.TestPath("/home/user/replace_symlink", vfst.TestModeType(os.ModeSymlink), vfst.TestSymlinkTarget("bar")),
 			},
 		},
 	} {
 		t.Run(tc.name, func(t *testing.T) {
-			fs, cleanup, err := vfstest.NewTempFS(tc.root)
+			fs, cleanup, err := vfst.NewTestFS(tc.root)
 			defer cleanup()
 			if err != nil {
-				t.Fatalf("vfstest.NewTempFS(_) == _, _, %v, want _, _, <nil>", err)
+				t.Fatalf("vfst.NewTestFS(_) == _, _, %v, want _, _, <nil>", err)
 			}
 			ts := NewTargetState(tc.targetDir, tc.umask, tc.sourceDir, tc.data)
 			if err := ts.Populate(fs); err != nil {
@@ -436,7 +436,7 @@ func TestEndToEnd(t *testing.T) {
 			if err := ts.Apply(fs, NewLoggingActuator(os.Stderr, NewFSActuator(fs, tc.targetDir))); err != nil {
 				t.Fatalf("ts.Apply(fs, _) == %v, want <nil>", err)
 			}
-			vfstest.RunTests(t, fs, "", tc.tests)
+			vfst.RunTests(t, fs, "", tc.tests)
 		})
 	}
 }