Skip to content

Commit

Permalink
(mr_create) update go-gitlab to include url encode for branches API a…
Browse files Browse the repository at this point in the history
…nd add tests for BranchPushed
  • Loading branch information
zaquestion committed Jan 7, 2018
1 parent fd87602 commit 1f3677c
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@

[[constraint]]
name = "github.com/xanzy/go-gitlab"
revision = "ec65bc7934094df33cb05d541a4ffadcd1f64861"
revision = "266c87ba209d842f6c190920a55db959e5b13971"
2 changes: 1 addition & 1 deletion cmd/clone_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ func Test_clone(t *testing.T) {
t.Log(out)

assert.Contains(t, out, "Cloning into 'test'...")
assert.Contains(t, out, " * [new branch] master -> upstream/master")
assert.Contains(t, out, " * [new branch] master -> upstream/master")
assert.Contains(t, out, "new remote: upstream")
}
1 change: 1 addition & 0 deletions internal/gitlab/gitlab.go
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ func SnippetList(opts *gitlab.ListSnippetsOptions) ([]*gitlab.Snippet, error) {
return snips, nil
}

// Lint validates .gitlab-ci.yml contents
func Lint(content string) (bool, error) {
lint, _, err := lab.Validate.Lint(content)
if err != nil {
Expand Down
33 changes: 33 additions & 0 deletions internal/gitlab/gitlab_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,41 @@ func TestLint(t *testing.T) {
for _, test := range tests {
t.Run(test.desc, func(t *testing.T) {
test := test
t.Parallel()
ok, _ := Lint(test.content)
require.Equal(t, test.expected, ok)
})
}
}

func TestBranchPushed(t *testing.T) {
tests := []struct {
desc string
branch string
expected bool
}{
{
"alpha is pushed",
"mrtest",
true,
},
{
"needs encoding is pushed",
"needs/encode",
true,
},
{
"alpha not pushed",
"not_a_branch",
false,
},
}
for _, test := range tests {
t.Run(test.desc, func(t *testing.T) {
test := test
t.Parallel()
ok := BranchPushed(4181224, test.branch)
require.Equal(t, test.expected, ok)
})
}
}

0 comments on commit 1f3677c

Please sign in to comment.