template / commit
Added a failure test and added version info to README.
README.md | 5 +++++ profile_test.go | 68 ++++++++++++++++++++++++++++++++++++++++----------------- 2 files changed, 53 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 43d482e..61c8968 100644 --- a/README.md +++ b/README.md @@ -120,6 +120,11 @@ For anything, open an issue in this repo. I'm going to use this tool daily to figure out how it can be improved. +While I am the only user, this app will stay at version `0.x.y`. +At this point, breaking changes may happen. + +Once there are enough other users and enough new feature requirements are added, we'll transition to version `1.x.y`. + ### Basic features Here are the basic features of the CLI that I want to keep: diff --git a/profile_test.go b/profile_test.go index a68d627..683aac4 100644 --- a/profile_test.go +++ b/profile_test.go @@ -247,27 +247,55 @@ func TestProcessProfile(t *testing.T) { } else { shell = "bash" } - profile := Profile{ - Path: cwd, - NamePatterns: []ParameterizedText{ - "{{.ProjectName}}-{{.Year}}-{{.Month}}-{{.Day}}-{{.Hour}}-{{.Minute}}-{{.Second}}", - }, - RunPostscriptOnFailure: true, - PostScripts: []ParameterizedText{ - "echo 'hi'", - }, - ScriptShell: shell, - } extras := map[string]string{ "foo": "bar", } - usr, err := user.Current() - assert.Nil(t, err) - assert.NotNil(t, usr) - errors := processProfile(profile, projectName, extras, *usr) - assert.Equal(t, 0, len(errors)) - assert.Equal(t, 1, len(monkeyPatchCalls.ExecCommandCalls)) - assert.Equal(t, 1, len(monkeyPatchCalls.OSChdirCalls)) - assert.Equal(t, 1, len(monkeyPatchCalls.OSGetwdCalls)) - assert.Equal(t, 1, len(monkeyPatchCalls.OSReadDirCalls)) + + testSuccess := func() { + profile := Profile{ + Path: cwd, + NamePatterns: []ParameterizedText{ + "{{.ProjectName}}-{{.Year}}-{{.Month}}-{{.Day}}-{{.Hour}}-{{.Minute}}-{{.Second}}", + }, + RunPostscriptOnFailure: true, + PostScripts: []ParameterizedText{ + "echo 'hi'", + }, + ScriptShell: shell, + } + + usr, err := user.Current() + assert.Nil(t, err) + assert.NotNil(t, usr) + errors := processProfile(profile, projectName, extras, *usr) + assert.Equal(t, 0, len(errors)) + assert.Equal(t, 1, len(monkeyPatchCalls.ExecCommandCalls)) + assert.Equal(t, 1, len(monkeyPatchCalls.OSChdirCalls)) + assert.Equal(t, 1, len(monkeyPatchCalls.OSGetwdCalls)) + assert.Equal(t, 1, len(monkeyPatchCalls.OSReadDirCalls)) + } + testFailure := func() { + profile := Profile{ + Path: cwd, + NamePatterns: []ParameterizedText{ + "{{.ProjectName", + }, + // RunPostscriptOnFailure: true, + PostScripts: []ParameterizedText{ + "echo 'hi'", + }, + ScriptShell: shell, + } + + usr, err := user.Current() + assert.Nil(t, err) + assert.NotNil(t, usr) + + errors := processProfile(profile, projectName, extras, *usr) + assert.Equal(t, 1, len(errors)) + } + + testSuccess() + + testFailure() }