harness-drone/vendor/github.com/Bugagazavr/go-gitlab-client/projects_test.go

86 lines
2.2 KiB
Go
Raw Normal View History

2015-07-26 23:25:20 +00:00
package gogitlab
import (
2015-08-06 16:22:31 +00:00
"github.com/drone/drone/Godeps/_workspace/src/github.com/stretchr/testify/assert"
2015-07-26 23:25:20 +00:00
"testing"
)
func TestALlProjects(t *testing.T) {
ts, gitlab := Stub("stubs/projects/index.json")
projects, err := gitlab.AllProjects()
assert.Equal(t, err, nil)
assert.Equal(t, len(projects), 2)
defer ts.Close()
}
func TestProjects(t *testing.T) {
ts, gitlab := Stub("stubs/projects/index.json")
projects, err := gitlab.Projects(1, 100)
assert.Equal(t, err, nil)
assert.Equal(t, len(projects), 2)
defer ts.Close()
}
func TestProject(t *testing.T) {
ts, gitlab := Stub("stubs/projects/show.json")
project, err := gitlab.Project("1")
assert.Equal(t, err, nil)
assert.IsType(t, new(Project), project)
assert.Equal(t, project.SshRepoUrl, "git@example.com:diaspora/diaspora-project-site.git")
assert.Equal(t, project.HttpRepoUrl, "http://example.com/diaspora/diaspora-project-site.git")
defer ts.Close()
}
func TestProjectBranches(t *testing.T) {
ts, gitlab := Stub("stubs/projects/branches/index.json")
branches, err := gitlab.ProjectBranches("1")
assert.Equal(t, err, nil)
assert.Equal(t, len(branches), 2)
defer ts.Close()
}
func TestProjectMergeRequests(t *testing.T) {
ts, gitlab := Stub("stubs/projects/merge_requests/index.json")
defer ts.Close()
mr, err := gitlab.ProjectMergeRequests("1", 0, 30, "all")
assert.Equal(t, err, nil)
assert.Equal(t, len(mr), 1)
if len(mr) > 0 {
assert.Equal(t, mr[0].TargetBranch, "master")
assert.Equal(t, mr[0].SourceBranch, "test1")
}
}
2015-08-22 03:32:22 +00:00
func TestMergeRequestNotes(t *testing.T) {
ts, gitlab := Stub("stubs/projects/merge_requests/notes/index.json")
defer ts.Close()
notes, err := gitlab.MergeRequestNotes("1", "1", 0, 30)
assert.Equal(t, err, nil)
assert.Equal(t, len(notes), 1)
if len(notes) > 0 {
assert.Equal(t, notes[0].Id, 301)
assert.Equal(t, notes[0].Body, "Comment for MR")
assert.Equal(t, notes[0].Author.Username, "pipin")
}
}
2015-07-26 23:25:20 +00:00
func TestSearchProjectId(t *testing.T) {
ts, gitlab := Stub("stubs/projects/index.json")
namespace := "Brightbox"
name := "Puppet"
id, err := gitlab.SearchProjectId(namespace, name)
assert.Equal(t, err, nil)
assert.Equal(t, id, 6)
defer ts.Close()
}