From 6ecbff88191b5a1e46ffdc982d2c931b26d48c9f Mon Sep 17 00:00:00 2001 From: Tom Payne Date: Sat, 22 Jun 2019 12:47:19 +0200 Subject: [PATCH 1/2] Use consistent email in tests --- cmd/init_test.go | 10 +++++----- docs/HOWTO.md | 2 +- lib/chezmoi/autotemplate_test.go | 8 ++++---- lib/chezmoi/targetstate_test.go | 10 +++++----- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/cmd/init_test.go b/cmd/init_test.go index 6a0b81b6e63..cef44ff88c5 100644 --- a/cmd/init_test.go +++ b/cmd/init_test.go @@ -28,7 +28,7 @@ func TestCreateConfigFile(t *testing.T) { conf := &Config{ SourceDir: "/home/user/.local/share/chezmoi", - stdin: bytes.NewBufferString("grace.hopper@example.com\n"), + stdin: bytes.NewBufferString("john.smith@company.com\n"), stdout: &bytes.Buffer{}, bds: xdg.NewTestBaseDirectorySpecification("/home/user", nil), } @@ -41,16 +41,16 @@ func TestCreateConfigFile(t *testing.T) { vfst.TestModePerm(0600), vfst.TestContentsString(strings.Join([]string{ `data:`, - ` email: "grace.hopper@example.com"`, - ` mailtoURL: "mailto:grace.hopper@example.com"`, + ` email: "john.smith@company.com"`, + ` mailtoURL: "mailto:john.smith@company.com"`, ` os: "` + runtime.GOOS + `"`, }, "\n")), ), ) assert.Equal(t, map[string]interface{}{ - "email": "grace.hopper@example.com", - "mailtourl": "mailto:grace.hopper@example.com", + "email": "john.smith@company.com", + "mailtourl": "mailto:john.smith@company.com", "os": runtime.GOOS, }, conf.Data) } diff --git a/docs/HOWTO.md b/docs/HOWTO.md index 509cc251104..cce7412242c 100644 --- a/docs/HOWTO.md +++ b/docs/HOWTO.md @@ -77,7 +77,7 @@ For example, your home `~/.gitconfig` on your personal machine might look like: Whereas at work it might be: [user] - email = "john@company.com" + email = "john.smith@company.com" To handle this, on each machine create a configuration file called `~/.config/chezmoi/chezmoi.toml` defining what might change. For your home diff --git a/lib/chezmoi/autotemplate_test.go b/lib/chezmoi/autotemplate_test.go index aed082b65d6..ea264165bf6 100644 --- a/lib/chezmoi/autotemplate_test.go +++ b/lib/chezmoi/autotemplate_test.go @@ -15,9 +15,9 @@ func TestAutoTemplate(t *testing.T) { }{ { name: "simple", - contentsStr: "email = hello@example.com\n", + contentsStr: "email = john.smith@company.com\n", data: map[string]interface{}{ - "email": "hello@example.com", + "email": "john.smith@company.com", }, wantStr: "email = {{ .email }}\n", }, @@ -42,10 +42,10 @@ func TestAutoTemplate(t *testing.T) { }, { name: "nested_values", - contentsStr: "email = hello@example.com\n", + contentsStr: "email = john.smith@company.com\n", data: map[string]interface{}{ "personal": map[string]interface{}{ - "email": "hello@example.com", + "email": "john.smith@company.com", }, }, wantStr: "email = {{ .personal.email }}\n", diff --git a/lib/chezmoi/targetstate_test.go b/lib/chezmoi/targetstate_test.go index b42a79982e7..e2c267acc03 100644 --- a/lib/chezmoi/targetstate_test.go +++ b/lib/chezmoi/targetstate_test.go @@ -52,7 +52,7 @@ func TestEndToEnd(t *testing.T) { sourceDir: "/home/user/.chezmoi", data: map[string]interface{}{ "name": "John Smith", - "email": "hello@example.com", + "email": "john.smith@company.com", "ignore": "README.md", }, destDir: "/home/user", @@ -64,7 +64,7 @@ func TestEndToEnd(t *testing.T) { ), vfst.TestPath("/home/user/.hgrc", vfst.TestModeIsRegular, - vfst.TestContentsString("[ui]\nusername = John Smith \n"), + vfst.TestContentsString("[ui]\nusername = John Smith \n"), ), vfst.TestPath("/home/user/foo", vfst.TestModeIsRegular, @@ -249,7 +249,7 @@ func TestTargetStatePopulate(t *testing.T) { }, sourceDir: "/", data: map[string]interface{}{ - "Email": "user@example.com", + "Email": "john.smith@company.com", }, want: &TargetState{ DestDir: "/", @@ -257,7 +257,7 @@ func TestTargetStatePopulate(t *testing.T) { Umask: 0, SourceDir: "/", Data: map[string]interface{}{ - "Email": "user@example.com", + "Email": "john.smith@company.com", }, Entries: map[string]Entry{ ".gitconfig": &File{ @@ -265,7 +265,7 @@ func TestTargetStatePopulate(t *testing.T) { targetName: ".gitconfig", Perm: 0666, Template: true, - contents: []byte("[user]\n\temail = user@example.com\n"), + contents: []byte("[user]\n\temail = john.smith@company.com\n"), }, }, }, From 957535f9d451661799b2c0bc060f405936426534 Mon Sep 17 00:00:00 2001 From: Tom Payne Date: Sat, 22 Jun 2019 12:47:37 +0200 Subject: [PATCH 2/2] Use consistent path to state database in tests --- lib/chezmoi/boltpersistentstate_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/chezmoi/boltpersistentstate_test.go b/lib/chezmoi/boltpersistentstate_test.go index 3c7dfe084e1..12670625090 100644 --- a/lib/chezmoi/boltpersistentstate_test.go +++ b/lib/chezmoi/boltpersistentstate_test.go @@ -17,7 +17,7 @@ func TestBoltPersistentState(t *testing.T) { require.NoError(t, err) defer cleanup() - path := "/home/user/.config/chezmoi/state.boltdb" + path := "/home/user/.config/chezmoi/chezmoistate.boltdb" b, err := NewBoltPersistentState(fs, path) require.NoError(t, err) vfst.RunTests(t, fs, "",