-
Notifications
You must be signed in to change notification settings - Fork 146
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Add tests for Repositories.GetFor(Account|Team) * Deprecate Repositories.GetForTeam (closes #181) Make Repositories.GetForTeam an alias to Repositories.GetForAccount, and mark the former as deprecated, since they both do the same.
- Loading branch information
Showing
2 changed files
with
95 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
package tests | ||
|
||
import ( | ||
"os" | ||
"testing" | ||
|
||
"github.com/ktrysmt/go-bitbucket" | ||
) | ||
|
||
func TestListForAccount(t *testing.T) { | ||
user := os.Getenv("BITBUCKET_TEST_USERNAME") | ||
pass := os.Getenv("BITBUCKET_TEST_PASSWORD") | ||
owner := os.Getenv("BITBUCKET_TEST_OWNER") | ||
repo := os.Getenv("BITBUCKET_TEST_REPOSLUG") | ||
|
||
if user == "" { | ||
t.Error("BITBUCKET_TEST_USERNAME is empty.") | ||
} | ||
if pass == "" { | ||
t.Error("BITBUCKET_TEST_PASSWORD is empty.") | ||
} | ||
if owner == "" { | ||
t.Error("BITBUCKET_TEST_OWNER is empty.") | ||
} | ||
if repo == "" { | ||
t.Error("BITBUCKET_TEST_REPOSLUG is empty.") | ||
} | ||
|
||
c := bitbucket.NewBasicAuth(user, pass) | ||
|
||
repositories, err := c.Repositories.ListForAccount(&bitbucket.RepositoriesOptions{ | ||
Owner: owner, | ||
}) | ||
if err != nil { | ||
t.Error("Unable to fetch repositories") | ||
} | ||
|
||
found := false | ||
for _, r := range repositories.Items { | ||
if r.Slug == repo { | ||
found = true | ||
break | ||
} | ||
} | ||
if !found { | ||
t.Error("Did not find repository in list") | ||
} | ||
} | ||
|
||
func TestListForTeam(t *testing.T) { | ||
user := os.Getenv("BITBUCKET_TEST_USERNAME") | ||
pass := os.Getenv("BITBUCKET_TEST_PASSWORD") | ||
owner := os.Getenv("BITBUCKET_TEST_OWNER") | ||
repo := os.Getenv("BITBUCKET_TEST_REPOSLUG") | ||
|
||
if user == "" { | ||
t.Error("BITBUCKET_TEST_USERNAME is empty.") | ||
} | ||
if pass == "" { | ||
t.Error("BITBUCKET_TEST_PASSWORD is empty.") | ||
} | ||
if owner == "" { | ||
t.Error("BITBUCKET_TEST_OWNER is empty.") | ||
} | ||
if repo == "" { | ||
t.Error("BITBUCKET_TEST_REPOSLUG is empty.") | ||
} | ||
|
||
c := bitbucket.NewBasicAuth(user, pass) | ||
|
||
//goland:noinspection GoDeprecation | ||
repositories, err := c.Repositories.ListForTeam(&bitbucket.RepositoriesOptions{ | ||
|
||
Owner: owner, | ||
}) | ||
if err != nil { | ||
t.Error("Unable to fetch repositories") | ||
} | ||
|
||
found := false | ||
for _, r := range repositories.Items { | ||
if r.Slug == repo { | ||
found = true | ||
break | ||
} | ||
} | ||
if !found { | ||
t.Error("Did not find repository in list") | ||
} | ||
} |