Skip to content

Commit

Permalink
Use consistent values in tests (#360)
Browse files Browse the repository at this point in the history
Use consistent values in tests
  • Loading branch information
twpayne committed Jun 22, 2019
2 parents 2983fc8 + 957535f commit a590114
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 deletions.
10 changes: 5 additions & 5 deletions cmd/init_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}
Expand All @@ -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)
}
2 changes: 1 addition & 1 deletion docs/HOWTO.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ For example, your home `~/.gitconfig` on your personal machine might look like:
Whereas at work it might be:

[user]
email = "[email protected]"
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
Expand Down
8 changes: 4 additions & 4 deletions lib/chezmoi/autotemplate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
Expand All @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion lib/chezmoi/boltpersistentstate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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, "",
Expand Down
10 changes: 5 additions & 5 deletions lib/chezmoi/targetstate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -64,7 +64,7 @@ func TestEndToEnd(t *testing.T) {
),
vfst.TestPath("/home/user/.hgrc",
vfst.TestModeIsRegular,
vfst.TestContentsString("[ui]\nusername = John Smith <hello@example.com>\n"),
vfst.TestContentsString("[ui]\nusername = John Smith <john.smith@company.com>\n"),
),
vfst.TestPath("/home/user/foo",
vfst.TestModeIsRegular,
Expand Down Expand Up @@ -249,23 +249,23 @@ func TestTargetStatePopulate(t *testing.T) {
},
sourceDir: "/",
data: map[string]interface{}{
"Email": "user@example.com",
"Email": "john.smith@company.com",
},
want: &TargetState{
DestDir: "/",
TargetIgnore: NewPatternSet(),
Umask: 0,
SourceDir: "/",
Data: map[string]interface{}{
"Email": "user@example.com",
"Email": "john.smith@company.com",
},
Entries: map[string]Entry{
".gitconfig": &File{
sourceName: "dot_gitconfig.tmpl",
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"),
},
},
},
Expand Down

0 comments on commit a590114

Please sign in to comment.