Skip to content

Commit 113f082

Browse files
committed
test: add list test in order to the issue #99.
1 parent 91a6098 commit 113f082

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

tests/list_test.go

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package tests
2+
3+
import (
4+
"fmt"
5+
"os"
6+
"testing"
7+
8+
"github.com/ktrysmt/go-bitbucket"
9+
)
10+
11+
func TestList(t *testing.T) {
12+
13+
user := os.Getenv("BITBUCKET_USERNAME")
14+
pass := os.Getenv("BITBUCKET_PASSWORD")
15+
owner := os.Getenv("BITBUCKET_OWNER")
16+
17+
c := bitbucket.NewBasicAuth(user, pass)
18+
19+
opt := &bitbucket.RepositoriesOptions{
20+
Owner: owner,
21+
}
22+
23+
repos, err := c.Repositories.ListForAccount(opt)
24+
25+
if err != nil {
26+
t.Error(err)
27+
}
28+
29+
for _, repo := range repos.Items {
30+
31+
tagOpt := &bitbucket.RepositoryTagOptions{
32+
Owner: owner,
33+
RepoSlug: repo.Slug,
34+
}
35+
res, err := c.Repositories.Repository.ListTags(tagOpt)
36+
37+
if err != nil {
38+
t.Error(err)
39+
}
40+
41+
if len(res.Tags) != 0 {
42+
for _, tag := range res.Tags {
43+
fmt.Println(tag.Name)
44+
}
45+
}
46+
}
47+
}

0 commit comments

Comments
 (0)