forked from plouc/go-gitlab-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgitlab_test.go
29 lines (23 loc) · 1.2 KB
/
gitlab_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package gogitlab
import (
"github.com/stretchr/testify/assert"
"testing"
)
func TestResourceUrl(t *testing.T) {
gitlab := NewGitlab("http://base_url/", "api_path", "token")
assert.Equal(t, gitlab.ResourceUrl(projects_url, nil), "http://base_url/api_path/projects?private_token=token")
assert.Equal(t, gitlab.ResourceUrl(project_url, map[string]string{":id": "123"}), "http://base_url/api_path/projects/123?private_token=token")
}
func TestResourceUrlRaw(t *testing.T) {
gitlab := NewGitlab("http://base_url/", "api_path", "token")
u, opaque := gitlab.ResourceUrlRaw(projects_url, map[string]string{":id": "123"})
assert.Equal(t, u, "http://base_url/api_path/projects?private_token=token")
assert.Equal(t, opaque, "//base_url/api_path/projects")
gitlab = NewGitlab("http://base/url/", "api_path", "token")
u, opaque = gitlab.ResourceUrlRaw(projects_url, nil)
assert.Equal(t, u, "http://base/url/api_path/projects?private_token=token")
assert.Equal(t, opaque, "//base/url/api_path/projects")
u, opaque = gitlab.ResourceUrlRaw(projects_url, map[string]string{":id": "123"})
assert.Equal(t, u, "http://base/url/api_path/projects?private_token=token")
assert.Equal(t, opaque, "//base/url/api_path/projects")
}