Inverting test logic and fixing extra --global

This commit is contained in:
Gary Holtz 2024-04-24 09:31:51 -05:00
parent d82c90021d
commit 3214a631f6
No known key found for this signature in database
GPG Key ID: 0C3B92677CFEE92F
1 changed files with 11 additions and 11 deletions

View File

@ -47,7 +47,7 @@ func initGitRepoWithCommit(t *testing.T) {
func configureGitConfig(t *testing.T) {
// CI will throw errors using a git command without a configuration
nameConfig := GitCommand("config", "--global", "user.name", "glab test bot")
nameConfig := GitCommand("config", "user.name", "glab test bot")
_, err := run.PrepareCmd(nameConfig).Output()
require.NoError(t, err)
@ -543,7 +543,16 @@ func TestListTags(t *testing.T) {
for name, tt := range cases {
t.Run(name, func(t *testing.T) {
if !tt.wantErr {
if tt.wantErr {
tempDir := t.TempDir()
// move to a directory without a .git subdirectory
err := os.Chdir(tempDir)
require.NoError(t, err)
tags, err := ListTags()
require.Equal(t, tt.errString, errors.Unwrap(err).Error())
require.Equal(t, tt.expected, tags)
} else {
initGitRepoWithCommit(t)
for tag := range tt.expected {
@ -554,15 +563,6 @@ func TestListTags(t *testing.T) {
tags, err := ListTags()
require.Equal(t, tt.expected, tags)
require.NoError(t, err)
} else {
tempDir := t.TempDir()
// move to a directory without a .git subdirectory
err := os.Chdir(tempDir)
require.NoError(t, err)
tags, err := ListTags()
require.Equal(t, tt.errString, errors.Unwrap(err).Error())
require.Equal(t, tt.expected, tags)
}
})
}