Merge branch 'ts-commands' of github.com:profclems/glab into ts-commands

This commit is contained in:
Clement Sam 2020-09-06 16:40:42 +00:00
commit 2821e38c29
7 changed files with 19 additions and 19 deletions

View File

@ -9,7 +9,7 @@ import (
"time"
)
func Test_IssueCreate (t *testing.T) {
func Test_IssueCreate(t *testing.T) {
rand.Seed(time.Now().UnixNano())
t.Parallel()
repo := copyTestRepo(t)
@ -33,4 +33,4 @@ func Test_IssueCreate (t *testing.T) {
assert.Contains(t, out, "Testing Issue Title")
assert.Contains(t, out, "https://gitlab.com/glab-cli/test/-/issues/")
}
}

View File

@ -3,9 +3,9 @@ package commands
import (
"fmt"
"github.com/profclems/glab/internal/utils"
"github.com/profclems/glab/internal/git"
"github.com/profclems/glab/internal/manip"
"github.com/profclems/glab/internal/utils"
"github.com/spf13/cobra"
"github.com/xanzy/go-gitlab"

View File

@ -23,4 +23,4 @@ func TestMrCmdWithArgs(t *testing.T) {
t.Log(out)
assert.Contains(t, out, "accepts 0 arg(s), received 1")
}
}

View File

@ -11,21 +11,21 @@ func Test_deleteMergeRequest(t *testing.T) {
repo := copyTestRepo(t)
var cmd *exec.Cmd
tests := []struct {
name string
args []string
wantErr bool
name string
args []string
wantErr bool
assertFunc func(t *testing.T, out string)
}{
{
name: "delete",
args: []string{"0"},
name: "delete",
args: []string{"0"},
wantErr: true,
assertFunc: func(t *testing.T, out string) {
assert.Contains(t, out, "404 Not Found")
},
},
{
name: "delete no args",
name: "delete no args",
wantErr: true,
assertFunc: func(t *testing.T, out string) {
assert.Contains(t, out, "accepts 1 arg(s), received 0")

View File

@ -34,7 +34,7 @@ func contains(arr []string, str string) bool {
return false
}
func fixRepoNamespace(repo string) (string, error) {
func fixRepoNamespace(repo string) (string, error) {
if !strings.Contains(repo, "/") {
u, err := currentUser()
if err != nil {

View File

@ -101,9 +101,9 @@ func init() {
// TODO: GetDefaultBranch looks really messy and should be fixed properly
// GetDefaultBranch finds the repo's default branch
func GetDefaultBranch(remote ...string) (string, error) {
func GetDefaultBranch(remote ...string) (string, error) {
var org string
if len(remote)>0 {
if len(remote) > 0 {
org = remote[0]
} else {
org = config.GetEnv("GIT_REMOTE_URL_VAR")
@ -122,7 +122,7 @@ func GetDefaultBranch(remote ...string) (string, error) {
p, t, u, org)
}
getDefBranch := exec.Command("git",
"remote","show", org)
"remote", "show", org)
output, err := run.PrepareCmd(getDefBranch).Output()
if err != nil {
return "master", err

View File

@ -276,13 +276,13 @@ func TestGetDefaultBranch(t *testing.T) {
args: "profclems/test",
},
{
name: "Invalid repo",
want: "master",
args: "testssz",
name: "Invalid repo",
want: "master",
args: "testssz",
wantErr: true,
},
}
for _, tt := range tests {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := GetDefaultBranch(tt.args)
if (err != nil) != tt.wantErr {
@ -294,4 +294,4 @@ func TestGetDefaultBranch(t *testing.T) {
}
})
}
}
}