Repository: twpayne/chezmoi
Pull request #234 (2019-03-24 15:04:54)

Switch to github.com/stretchr/testify for testing


Patch:
diff --git a/go.mod b/go.mod
index 408ec4b0e..31472507b 100644
--- a/go.mod
+++ b/go.mod
@@ -8,7 +8,6 @@ require (
 	github.com/Masterminds/sprig v2.17.1+incompatible
 	github.com/aokoli/goutils v1.1.0 // indirect
 	github.com/coreos/go-semver v0.2.0
-	github.com/d4l3k/messagediff v1.2.1
 	github.com/danieljoos/wincred v1.0.1 // indirect
 	github.com/godbus/dbus v4.1.0+incompatible // indirect
 	github.com/google/renameio v0.1.0
@@ -20,6 +19,7 @@ require (
 	github.com/spf13/cobra v0.0.3
 	github.com/spf13/viper v1.3.1
 	github.com/stretchr/objx v0.1.1 // indirect
+	github.com/stretchr/testify v1.3.0
 	github.com/twpayne/go-shell v0.0.1
 	github.com/twpayne/go-vfs v1.0.5
 	github.com/twpayne/go-xdg/v2 v2.0.0
diff --git a/go.sum b/go.sum
index e6cf94684..afec868fe 100644
--- a/go.sum
+++ b/go.sum
@@ -11,8 +11,6 @@ github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc
 github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk=
 github.com/coreos/go-semver v0.2.0 h1:3Jm3tLmsgAYcjC+4Up7hJrFBPr+n7rAqYeSw/SZazuY=
 github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
-github.com/d4l3k/messagediff v1.2.1 h1:ZcAIMYsUg0EAp9X+tt8/enBE/Q8Yd5kzPynLyKptt9U=
-github.com/d4l3k/messagediff v1.2.1/go.mod h1:Oozbb1TVXFac9FtSIxHBMnBCq2qeH/2KkEQxENCrlLo=
 github.com/danieljoos/wincred v1.0.1 h1:fcRTaj17zzROVqni2FiToKUVg3MmJ4NtMSGCySPIr/g=
 github.com/danieljoos/wincred v1.0.1/go.mod h1:SnuYRW9lp1oJrZX/dXJqr0cPK5gYXqx3EJbmjhLdK9U=
 github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=


Test patch:
diff --git a/cmd/add_test.go b/cmd/add_test.go
index 342a0084c..40d832d6f 100644
--- a/cmd/add_test.go
+++ b/cmd/add_test.go
@@ -3,6 +3,8 @@ package cmd
 import (
 	"testing"
 
+	"github.com/stretchr/testify/assert"
+	"github.com/stretchr/testify/require"
 	"github.com/twpayne/chezmoi/lib/chezmoi"
 	"github.com/twpayne/go-vfs/vfst"
 )
@@ -20,26 +22,18 @@ func TestAddAfterModification(t *testing.T) {
 		"/home/user/.chezmoi": &vfst.Dir{Perm: 0700},
 		"/home/user/.bashrc":  "# contents of .bashrc\n",
 	})
+	require.NoError(t, err)
 	defer cleanup()
-	if err != nil {
-		t.Fatalf("vfst.NewTestFS(_) == _, _, %v, want _, _, <nil>", err)
-	}
 	args := []string{"/home/user/.bashrc"}
-	if err := c.runAddCmd(fs, args); err != nil {
-		t.Errorf("c.runAddCmd(fs, nil, %+v) == %v, want <nil>", args, err)
-	}
+	assert.NoError(t, c.runAddCmd(fs, args))
 	vfst.RunTests(t, fs, "",
 		vfst.TestPath("/home/user/.chezmoi/dot_bashrc",
 			vfst.TestModeIsRegular,
 			vfst.TestContentsString("# contents of .bashrc\n"),
 		),
 	)
-	if err := fs.WriteFile("/home/user/.bashrc", []byte("# new contents of .bashrc\n"), 0644); err != nil {
-		t.Errorf("fs.WriteFile(...) == %v, want <nil>", err)
-	}
-	if err := c.runAddCmd(fs, args); err != nil {
-		t.Errorf("c.runAddCmd(fs, nil, %+v) == %v, want <nil>", args, err)
-	}
+	assert.NoError(t, fs.WriteFile("/home/user/.bashrc", []byte("# new contents of .bashrc\n"), 0644))
+	assert.NoError(t, c.runAddCmd(fs, args))
 	vfst.RunTests(t, fs, "",
 		vfst.TestPath("/home/user/.chezmoi/dot_bashrc",
 			vfst.TestModeIsRegular,
@@ -314,13 +308,9 @@ func TestAddCommand(t *testing.T) {
 				add: tc.add,
 			}
 			fs, cleanup, err := vfst.NewTestFS(tc.root)
+			require.NoError(t, err)
 			defer cleanup()
-			if err != nil {
-				t.Fatalf("vfst.NewTestFS(_) == _, _, %v, want _, _, <nil>", err)
-			}
-			if err := c.runAddCmd(fs, tc.args); err != nil {
-				t.Errorf("c.runAddCmd(fs, nil, %+v) == %v, want <nil>", tc.args, err)
-			}
+			assert.NoError(t, c.runAddCmd(fs, tc.args))
 			vfst.RunTests(t, fs, "", tc.tests)
 		})
 	}
diff --git a/cmd/chattr_test.go b/cmd/chattr_test.go
index 2227b4256..1cbf80caa 100644
--- a/cmd/chattr_test.go
+++ b/cmd/chattr_test.go
@@ -1,9 +1,10 @@
 package cmd
 
 import (
-	"reflect"
 	"testing"
 
+	"github.com/stretchr/testify/assert"
+	"github.com/stretchr/testify/require"
 	"github.com/twpayne/go-vfs/vfst"
 )
 
@@ -291,13 +292,9 @@ func TestChattrCommand(t *testing.T) {
 				Verbose:   true,
 			}
 			fs, cleanup, err := vfst.NewTestFS(tc.root)
-			if err != nil {
-				t.Fatalf("vfst.NewTestFS(_) == _, _, %v, want _, _, <nil>", err)
-			}
+			require.NoError(t, err)
 			defer cleanup()
-			if err := c.runChattrCmd(fs, tc.args); err != nil {
-				t.Errorf("c.runChattrCmd(fs, nil, %+v) == %v, want <nil>", tc.args, err)
-			}
+			assert.NoError(t, c.runChattrCmd(fs, tc.args))
 			vfst.RunTests(t, fs, "", tc.tests)
 		})
 	}
@@ -350,12 +347,12 @@ func TestParseAttributeModifiers(t *testing.T) {
 		{s: " empty , -private, notemplate ", want: &attributeModifiers{empty: 1, private: -1, template: -1}},
 		{s: "empty,,-private", want: &attributeModifiers{empty: 1, private: -1}},
 	} {
-		if got, gotErr := parseAttributeModifiers(tc.s); (gotErr != nil && !tc.wantErr) || (gotErr == nil && tc.wantErr) || !reflect.DeepEqual(got, tc.want) {
-			wantErrStr := "<nil>"
-			if tc.wantErr {
-				wantErrStr = "!" + wantErrStr
-			}
-			t.Errorf("parseAttributeModifiers(%q) == %+v, %v, want %+v, %s", tc.s, got, gotErr, tc.want, wantErrStr)
+		got, gotErr := parseAttributeModifiers(tc.s)
+		if tc.wantErr {
+			assert.Error(t, gotErr)
+		} else {
+			assert.NoError(t, gotErr)
+			assert.Equal(t, tc.want, got)
 		}
 	}
 }
diff --git a/cmd/cmd_test.go b/cmd/cmd_test.go
index d5ed6e9ad..1f5229a9f 100644
--- a/cmd/cmd_test.go
+++ b/cmd/cmd_test.go
@@ -4,6 +4,8 @@ import (
 	"os"
 	"testing"
 
+	"github.com/stretchr/testify/assert"
+	"github.com/stretchr/testify/require"
 	"github.com/twpayne/go-vfs/vfst"
 )
 
@@ -12,10 +14,8 @@ func TestExercise(t *testing.T) {
 	fs, cleanup, err := vfst.NewTestFS(map[string]interface{}{
 		"/home/user/.bashrc": "# contents of .bashrc\n",
 	})
+	require.NoError(t, err)
 	defer cleanup()
-	if err != nil {
-		t.Fatalf("vfst.NewTestFS() == _, _, %v, want _, _, <nil>", err)
-	}
 
 	c := &Config{
 		SourceDir: "/home/user/.chezmoi",
@@ -25,16 +25,12 @@ func TestExercise(t *testing.T) {
 	}
 
 	mustWriteFile := func(name, contents string, mode os.FileMode) {
-		if err := fs.WriteFile(name, []byte(contents), mode); err != nil {
-			t.Errorf("fs.WriteFile(%q, []byte(%q), %o) == %v, want <nil>", name, contents, mode, err)
-		}
+		assert.NoError(t, fs.WriteFile(name, []byte(contents), mode))
 	}
 
 	// chezmoi add ~/.bashrc
 	t.Run("chezmoi_add_bashrc", func(t *testing.T) {
-		if err := c.runAddCmd(fs, []string{"/home/user/.bashrc"}); err != nil {
-			t.Errorf("c.runAddCmd(...) == %v, want <nil>", err)
-		}
+		assert.NoError(t, c.runAddCmd(fs, []string{"/home/user/.bashrc"}))
 		vfst.RunTests(t, fs, "",
 			vfst.TestPath("/home/user/.chezmoi",
 				vfst.TestIsDir,
@@ -50,9 +46,7 @@ func TestExercise(t *testing.T) {
 
 	// chezmoi forget ~/.bashrc
 	t.Run("chezmoi_forget_bashrc", func(t *testing.T) {
-		if err := c.runForgetCmd(fs, []string{"/home/user/.bashrc"}); err != nil {
-			t.Errorf("c.runForgetCmd(...) == %v, want <nil>", err)
-		}
+		assert.NoError(t, c.runForgetCmd(fs, []string{"/home/user/.bashrc"}))
 		vfst.RunTests(t, fs, "",
 			vfst.TestPath("/home/user/.chezmoi/dot_bashrc",
 				vfst.TestDoesNotExist,
@@ -63,9 +57,7 @@ func TestExercise(t *testing.T) {
 	// chezmoi add ~/.netrc
 	t.Run("chezmoi_add_netrc", func(t *testing.T) {
 		mustWriteFile("/home/user/.netrc", "# contents of .netrc\n", 0600)
-		if err := c.runAddCmd(fs, []string{"/home/user/.netrc"}); err != nil {
-			t.Errorf("c.runAddCmd(...) == %v, want <nil>", err)
-		}
+		assert.NoError(t, c.runAddCmd(fs, []string{"/home/user/.netrc"}))
 		vfst.RunTests(t, fs, "",
 			vfst.TestPath("/home/user/.chezmoi/private_dot_netrc",
 				vfst.TestModeIsRegular,
@@ -77,9 +69,7 @@ func TestExercise(t *testing.T) {
 
 	// chezmoi chattr -- -private,+empty ~/.netrc
 	t.Run("chezmoi_chattr_netrc", func(t *testing.T) {
-		if err := c.runChattrCmd(fs, []string{"-private,+empty", "/home/user/.netrc"}); err != nil {
-			t.Errorf("c.runChattrCmd(...) == %v, want <nil>", err)
-		}
+		assert.NoError(t, c.runChattrCmd(fs, []string{"-private,+empty", "/home/user/.netrc"}))
 		vfst.RunTests(t, fs, "",
 			vfst.TestPath("/home/user/.chezmoi/empty_dot_netrc",
 				vfst.TestModeIsRegular,
@@ -91,9 +81,7 @@ func TestExercise(t *testing.T) {
 
 	// chezmoi apply ~/.netrc
 	t.Run("chezmoi_apply_netrc", func(t *testing.T) {
-		if err := c.runApplyCmd(fs, []string{"/home/user/.netrc"}); err != nil {
-			t.Errorf("c.runApplyCmd(...) == %v, want <nil>", err)
-		}
+		assert.NoError(t, c.runApplyCmd(fs, []string{"/home/user/.netrc"}))
 		vfst.RunTests(t, fs, "",
 			vfst.TestPath("/home/user/.netrc",
 				vfst.TestModeIsRegular,
@@ -105,9 +93,7 @@ func TestExercise(t *testing.T) {
 
 	// chezmoi remove ~/.netrc
 	t.Run("chezmoi_remove_netrc", func(t *testing.T) {
-		if err := c.runRemoveCmd(fs, []string{"/home/user/.netrc"}); err != nil {
-			t.Errorf("c.runRemoveCmd(...) == %v, want <nil>", err)
-		}
+		assert.NoError(t, c.runRemoveCmd(fs, []string{"/home/user/.netrc"}))
 		vfst.RunTests(t, fs, "",
 			vfst.TestPath("/home/user/.netrc",
 				vfst.TestDoesNotExist,
diff --git a/cmd/config_test.go b/cmd/config_test.go
index eff34553e..84d9a7bca 100644
--- a/cmd/config_test.go
+++ b/cmd/config_test.go
@@ -1,6 +1,10 @@
 package cmd
 
-import "testing"
+import (
+	"testing"
+
+	"github.com/stretchr/testify/assert"
+)
 
 func TestUpperSnakeCaseToCamelCase(t *testing.T) {
 	for s, want := range map[string]string{
@@ -11,8 +15,6 @@ func TestUpperSnakeCaseToCamelCase(t *testing.T) {
 		"VERSION_CODENAME": "versionCodename",
 		"VERSION_ID":       "versionID",
 	} {
-		if got := upperSnakeCaseToCamelCase(s); got != want {
-			t.Errorf("upperSnakeCaseToCamelCase(%q) == %q, want %q", s, got, want)
-		}
+		assert.Equal(t, want, upperSnakeCaseToCamelCase(s))
 	}
 }
diff --git a/cmd/os_release_test.go b/cmd/os_release_test.go
index bb05e09f3..2a7f20397 100644
--- a/cmd/os_release_test.go
+++ b/cmd/os_release_test.go
@@ -4,7 +4,8 @@ import (
 	"bytes"
 	"testing"
 
-	"github.com/d4l3k/messagediff"
+	"github.com/stretchr/testify/assert"
+	"github.com/stretchr/testify/require"
 	"github.com/twpayne/go-vfs/vfst"
 )
 
@@ -73,15 +74,11 @@ UBUNTU_CODENAME=bionic`,
 	} {
 		t.Run(tc.name, func(t *testing.T) {
 			fs, cleanup, err := vfst.NewTestFS(tc.root)
-			if err != nil {
-				t.Fatalf("vfst.NewTestFS(_) == _, _, %v, want _, _, <nil>", err)
-			}
+			require.NoError(t, err)
 			defer cleanup()
 			got, gotErr := getOSRelease(fs)
-			diff, equal := messagediff.PrettyDiff(tc.want, got)
-			if gotErr != nil || !equal {
-				t.Errorf("getOSRelease(fs) == %v, %v, want %v, <nil>\n%s", got, gotErr, tc.want, diff)
-			}
+			assert.NoError(t, gotErr)
+			assert.Equal(t, tc.want, got)
 		})
 	}
 }
@@ -146,27 +143,7 @@ UBUNTU_CODENAME=bionic`,
 		},
 	} {
 		got, gotErr := parseOSRelease(bytes.NewBufferString(tc.s))
-		diff, equal := messagediff.PrettyDiff(tc.want, got)
-		if gotErr != nil || !equal {
-			t.Errorf("parseOSRelease(bytes.NewBufferString(%q)) == %+v, %v, want %+v, <nil>\n%s", tc.s, got, gotErr, tc.want, diff)
-		}
-	}
-}
-
-func TestUppercaseSnakeToCamelCase(t *testing.T) {
-	for _, tc := range []struct {
-		s    string
-		want string
-	}{
-		{s: "ID", want: "id"},
-		{s: "NAME", want: "name"},
-		{s: "ID_LIKE", want: "idLike"},
-		{s: "PRETTY_NAME", want: "prettyName"},
-		{s: "ANSI_COLOR", want: "ansiColor"},
-		{s: "BUG_REPORT_URL", want: "bugReportURL"},
-	} {
-		if got := upperSnakeCaseToCamelCase(tc.s); got != tc.want {
-			t.Errorf("uppercaseSnakeToCamelCase(%q) == %q, want %q", tc.s, got, tc.want)
-		}
+		assert.NoError(t, gotErr)
+		assert.Equal(t, tc.want, got)
 	}
 }
diff --git a/cmd/secret_lastpass_test.go b/cmd/secret_lastpass_test.go
index c7b4cae24..a5167cf81 100644
--- a/cmd/secret_lastpass_test.go
+++ b/cmd/secret_lastpass_test.go
@@ -3,7 +3,7 @@ package cmd
 import (
 	"testing"
 
-	"github.com/d4l3k/messagediff"
+	"github.com/stretchr/testify/assert"
 )
 
 func Test_lastpassParseNote(t *testing.T) {
@@ -39,9 +39,6 @@ func Test_lastpassParseNote(t *testing.T) {
 			},
 		},
 	} {
-		got := lastpassParseNote(tc.note)
-		if diff, equal := messagediff.PrettyDiff(tc.want, got); !equal {
-			t.Errorf("lastpassParseNote(%q) == %+v, want %+v\n%s", tc.note, got, tc.want, diff)
-		}
+		assert.Equal(t, tc.want, lastpassParseNote(tc.note))
 	}
 }
diff --git a/lib/chezmoi/autotemplate_test.go b/lib/chezmoi/autotemplate_test.go
index 83fab0d2d..8f1d895c0 100644
--- a/lib/chezmoi/autotemplate_test.go
+++ b/lib/chezmoi/autotemplate_test.go
@@ -1,6 +1,10 @@
 package chezmoi
 
-import "testing"
+import (
+	"testing"
+
+	"github.com/stretchr/testify/assert"
+)
 
 func TestAutoTemplate(t *testing.T) {
 	for _, tc := range []struct {
@@ -121,10 +125,8 @@ func TestAutoTemplate(t *testing.T) {
 	} {
 		t.Run(tc.name, func(t *testing.T) {
 			got, gotErr := autoTemplate([]byte(tc.contentsStr), tc.data)
-			gotStr := string(got)
-			if gotErr != nil || gotStr != tc.wantStr {
-				t.Errorf("autoTemplate([]byte(%q), %v) == %q, %v, want %q, <nil>", tc.contentsStr, tc.data, gotStr, gotErr, tc.wantStr)
-			}
+			assert.NoError(t, gotErr)
+			assert.Equal(t, tc.wantStr, string(got))
 		})
 	}
 }
@@ -163,8 +165,6 @@ func TestInWord(t *testing.T) {
 		{s: "/home/user", i: 9, want: true},
 		{s: "/home/user", i: 10, want: false},
 	} {
-		if got := inWord(tc.s, tc.i); got != tc.want {
-			t.Errorf("inWord(%q, %d) == %v, want %v", tc.s, tc.i, got, tc.want)
-		}
+		assert.Equal(t, tc.want, inWord(tc.s, tc.i))
 	}
 }
diff --git a/lib/chezmoi/chezmoi_test.go b/lib/chezmoi/chezmoi_test.go
index 358650330..27af2aec0 100644
--- a/lib/chezmoi/chezmoi_test.go
+++ b/lib/chezmoi/chezmoi_test.go
@@ -3,6 +3,8 @@ package chezmoi
 import (
 	"errors"
 	"testing"
+
+	"github.com/stretchr/testify/assert"
 )
 
 func TestReturnTemplateError(t *testing.T) {
@@ -20,9 +22,8 @@ func TestReturnTemplateError(t *testing.T) {
 	} {
 		t.Run(name, func(t *testing.T) {
 			ts := NewTargetState("/home/user", 0, "/home/user/.chezmoi", nil, funcs, "")
-			if got, err := ts.executeTemplateData(name, []byte(dataString)); err == nil {
-				t.Errorf("ts.executeTemplate(%q, %q) == %q, <nil>, want _, !<nil>", name, dataString, got)
-			}
+			_, err := ts.executeTemplateData(name, []byte(dataString))
+			assert.Error(t, err)
 		})
 	}
 }
diff --git a/lib/chezmoi/dir_test.go b/lib/chezmoi/dir_test.go
index 8e670ce29..02b7b3c2e 100644
--- a/lib/chezmoi/dir_test.go
+++ b/lib/chezmoi/dir_test.go
@@ -3,7 +3,7 @@ package chezmoi
 import (
 	"testing"
 
-	"github.com/d4l3k/messagediff"
+	"github.com/stretchr/testify/assert"
 )
 
 func TestDirAttributes(t *testing.T) {
@@ -57,13 +57,8 @@ func TestDirAttributes(t *testing.T) {
 		},
 	} {
 		t.Run(tc.sourceName, func(t *testing.T) {
-			gotDA := ParseDirAttributes(tc.sourceName)
-			if diff, equal := messagediff.PrettyDiff(tc.da, gotDA); !equal {
-				t.Errorf("ParseDirAttributes(%q) == %+v, want %+v, diff:\n%s", tc.sourceName, gotDA, tc.da, diff)
-			}
-			if gotSourceName := tc.da.SourceName(); gotSourceName != tc.sourceName {
-				t.Errorf("%+v.SourceName() == %q, want %q", tc.da, gotSourceName, tc.sourceName)
-			}
+			assert.Equal(t, tc.da, ParseDirAttributes(tc.sourceName))
+			assert.Equal(t, tc.sourceName, tc.da.SourceName())
 		})
 	}
 }
diff --git a/lib/chezmoi/file_test.go b/lib/chezmoi/file_test.go
index 2aad3d00e..305daffad 100644
--- a/lib/chezmoi/file_test.go
+++ b/lib/chezmoi/file_test.go
@@ -4,7 +4,7 @@ import (
 	"os"
 	"testing"
 
-	"github.com/d4l3k/messagediff"
+	"github.com/stretchr/testify/assert"
 )
 
 func TestFileAttributes(t *testing.T) {
@@ -116,13 +116,8 @@ func TestFileAttributes(t *testing.T) {
 		},
 	} {
 		t.Run(tc.sourceName, func(t *testing.T) {
-			gotFA := ParseFileAttributes(tc.sourceName)
-			if diff, equal := messagediff.PrettyDiff(tc.fa, gotFA); !equal {
-				t.Errorf("ParseFileAttributes(%q) == %+v, want %+v, diff:\n%s", tc.sourceName, gotFA, tc.fa, diff)
-			}
-			if gotSourceName := tc.fa.SourceName(); gotSourceName != tc.sourceName {
-				t.Errorf("%+v.SourceName() == %q, want %q", tc.fa, gotSourceName, tc.sourceName)
-			}
+			assert.Equal(t, tc.fa, ParseFileAttributes(tc.sourceName))
+			assert.Equal(t, tc.sourceName, tc.fa.SourceName())
 		})
 	}
 }
diff --git a/lib/chezmoi/target_state_test.go b/lib/chezmoi/target_state_test.go
index 30add22d4..183eeff2f 100644
--- a/lib/chezmoi/target_state_test.go
+++ b/lib/chezmoi/target_state_test.go
@@ -5,7 +5,8 @@ import (
 	"testing"
 	"text/template"
 
-	"github.com/d4l3k/messagediff"
+	"github.com/stretchr/testify/assert"
+	"github.com/stretchr/testify/require"
 	"github.com/twpayne/go-vfs/vfst"
 )
 
@@ -93,17 +94,11 @@ func TestEndToEnd(t *testing.T) {
 	} {
 		t.Run(tc.name, func(t *testing.T) {
 			fs, cleanup, err := vfst.NewTestFS(tc.root)
+			require.NoError(t, err)
 			defer cleanup()
-			if err != nil {
-				t.Fatalf("vfst.NewTestFS(_) == _, _, %v, want _, _, <nil>", err)
-			}
 			ts := NewTargetState(tc.destDir, tc.umask, tc.sourceDir, tc.data, tc.templateFuncs, "")
-			if err := ts.Populate(fs); err != nil {
-				t.Fatalf("ts.Populate(%+v) == %v, want <nil>", fs, err)
-			}
-			if err := ts.Apply(fs, NewLoggingMutator(os.Stderr, NewFSMutator(fs, tc.destDir))); err != nil {
-				t.Fatalf("ts.Apply(fs, _) == %v, want <nil>", err)
-			}
+			assert.NoError(t, ts.Populate(fs))
+			assert.NoError(t, ts.Apply(fs, NewLoggingMutator(os.Stderr, NewFSMutator(fs, tc.destDir))))
 			vfst.RunTests(t, fs, "", tc.tests)
 		})
 	}
@@ -405,20 +400,12 @@ func TestTargetStatePopulate(t *testing.T) {
 	} {
 		t.Run(tc.name, func(t *testing.T) {
 			fs, cleanup, err := vfst.NewTestFS(tc.root)
+			require.NoError(t, err)
 			defer cleanup()
-			if err != nil {
-				t.Fatalf("vfst.NewTestFS(_) == _, _, %v, want _, _, <nil>", err)
-			}
 			ts := NewTargetState("/", 0, tc.sourceDir, tc.data, tc.templateFuncs, "")
-			if err := ts.Populate(fs); err != nil {
-				t.Fatalf("ts.Populate(%+v) == %v, want <nil>", fs, err)
-			}
-			if err := ts.Evaluate(); err != nil {
-				t.Errorf("ts.Evaluate() == %v, want <nil>", err)
-			}
-			if diff, equal := messagediff.PrettyDiff(tc.want, ts); !equal {
-				t.Errorf("ts.Populate(%+v) diff:\n%s\n", fs, diff)
-			}
+			assert.NoError(t, ts.Populate(fs))
+			assert.NoError(t, ts.Evaluate())
+			assert.Equal(t, tc.want, ts)
 		})
 	}
 }