-
-
Notifications
You must be signed in to change notification settings - Fork 293
fix(778): git bug rm broken #808
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
1659fed
test(778): capture stderr and stdout during tests
smoyer64 523a148
test(778): allow alternate CWD via context
smoyer64 5962ed8
test(778): verify root command returns main help text
smoyer64 50324b8
test(778): verify user create results in an identity and cache
smoyer64 508d0eb
test(778): clear output after user creation
smoyer64 ecfffe3
test(778): execute add user in testEnv and return userID
smoyer64 90208b5
test(778): execute rm bug in testEnv (hangs)
smoyer64 eda312f
fix(778): remove extra mutex lock when resolving bug prefix
smoyer64 cd1099a
fix(808): replace Windows line terminators
smoyer64 8fc93d8
Merge branch 'master' into fix/778-git-bug-rm-broken
smoyer64 5982e8f
chore(808): merge in LocalStorage namespace configuration
smoyer64 1a504e0
fix(808): simplify handling of Windows line terminations
smoyer64 99669d7
test(808): do not run golden file tests on Windows
smoyer64 54306a8
test(808): make build tag compatible with Go 1.16
smoyer64 848f725
fix(808): remove duplication stderr/stdout set-up
smoyer64 f0f5247
test(808): skip root help test that uses a golden file
smoyer64 6ec7d67
test(808): document getCWD() and clean-up arguments
smoyer64 941f5b3
chore(808): rearrange imports to git-bug convention
smoyer64 0a9aaa9
refactor(778): test only command implementations
smoyer64 d853a6f
test(778): simplify and guarantee backend cleanup
smoyer64 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| package commands | ||
|
|
||
| import ( | ||
| "strings" | ||
| "testing" | ||
|
|
||
| "github.com/stretchr/testify/require" | ||
| ) | ||
|
|
||
| func newTestEnvUserAndBug(t *testing.T) (*testEnv, string, string) { | ||
| t.Helper() | ||
|
|
||
| testEnv, userID := newTestEnvAndUser(t) | ||
| opts := addOptions{ | ||
| title: "this is a bug title", | ||
| message: "this is a bug message", | ||
| messageFile: "", | ||
| nonInteractive: true, | ||
| } | ||
|
|
||
| require.NoError(t, runAdd(testEnv.env, opts)) | ||
| require.Regexp(t, "^[0-9A-Fa-f]{7} created\n$", testEnv.out) | ||
| bugID := strings.Split(testEnv.out.String(), " ")[0] | ||
| testEnv.out.Reset() | ||
|
|
||
| return testEnv, userID, bugID | ||
| } | ||
|
|
||
| func TestAdd(t *testing.T) { | ||
| _, _, user := newTestEnvUserAndBug(t) | ||
| require.Regexp(t, "^[0-9A-Fa-f]{7}$", user) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| package commands | ||
|
|
||
| import ( | ||
| "bytes" | ||
| "testing" | ||
|
|
||
| "github.com/stretchr/testify/require" | ||
|
|
||
| "github.com/MichaelMure/git-bug/cache" | ||
| "github.com/MichaelMure/git-bug/repository" | ||
| ) | ||
|
|
||
| type testEnv struct { | ||
| env *Env | ||
| cwd string | ||
| out *bytes.Buffer | ||
| } | ||
|
|
||
| func newTestEnv(t *testing.T) *testEnv { | ||
| t.Helper() | ||
|
|
||
| cwd := t.TempDir() | ||
|
|
||
| repo, err := repository.InitGoGitRepo(cwd, gitBugNamespace) | ||
| require.NoError(t, err) | ||
| t.Cleanup(func() { | ||
| require.NoError(t, repo.Close()) | ||
| }) | ||
|
|
||
| buf := new(bytes.Buffer) | ||
|
|
||
| backend, err := cache.NewRepoCache(repo) | ||
| require.NoError(t, err) | ||
| t.Cleanup(func() { | ||
| backend.Close() | ||
| }) | ||
|
|
||
| return &testEnv{ | ||
| env: &Env{ | ||
| repo: repo, | ||
| backend: backend, | ||
| out: out{Writer: buf}, | ||
| err: out{Writer: buf}, | ||
| }, | ||
| cwd: cwd, | ||
| out: buf, | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| package commands | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| "github.com/stretchr/testify/require" | ||
| ) | ||
|
|
||
| func TestRm(t *testing.T) { | ||
| testEnv, _, bugID := newTestEnvUserAndBug(t) | ||
|
|
||
| exp := "bug " + bugID + " removed\n" | ||
|
|
||
| require.NoError(t, runRm(testEnv.env, []string{bugID})) | ||
| require.Equal(t, exp, testEnv.out.String()) | ||
| testEnv.out.Reset() | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| package commands | ||
|
|
||
| import ( | ||
| "path/filepath" | ||
| "strings" | ||
| "testing" | ||
|
|
||
| "github.com/stretchr/testify/require" | ||
| ) | ||
|
|
||
| func newTestEnvAndUser(t *testing.T) (*testEnv, string) { | ||
| t.Helper() | ||
|
|
||
| testEnv := newTestEnv(t) | ||
|
|
||
| opts := createUserOptions{ | ||
| name: "John Doe", | ||
| email: "jdoe@example.com", | ||
| avatarURL: "", | ||
| nonInteractive: true, | ||
| } | ||
|
|
||
| require.NoError(t, runUserCreate(testEnv.env, opts)) | ||
|
|
||
| userID := strings.TrimSpace(testEnv.out.String()) | ||
| testEnv.out.Reset() | ||
|
|
||
| return testEnv, userID | ||
| } | ||
|
|
||
| func TestUserCreateCommand(t *testing.T) { | ||
| testEnv, userID := newTestEnvAndUser(t) | ||
|
|
||
| require.FileExists(t, filepath.Join(testEnv.cwd, ".git", "refs", "identities", userID)) | ||
| require.FileExists(t, filepath.Join(testEnv.cwd, ".git", "git-bug", "identity-cache")) | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.