diff --git a/src/BitbucketPharoAPI-Tests/BitbucketRepositoriesTest.class.st b/src/BitbucketPharoAPI-Tests/BitbucketRepositoriesTest.class.st index 13c1111..bf0aa16 100644 --- a/src/BitbucketPharoAPI-Tests/BitbucketRepositoriesTest.class.st +++ b/src/BitbucketPharoAPI-Tests/BitbucketRepositoriesTest.class.st @@ -8,6 +8,37 @@ Class { #package : 'BitbucketPharoAPI-Tests' } +{ #category : 'tests' } +BitbucketRepositoriesTest >> testAllInProject [ + + | hostUrl client bitbucketApi projectKey endpoint response result bitbucketRepos | + hostUrl := 'www.url.com'. + client := Mock new. + + bitbucketApi := BitbucketApi new + bearerToken: 'token'; + host: hostUrl; + client: client. + + bitbucketRepos := BitbucketRepositories new bitbucketApi: + bitbucketApi. + + projectKey := 'OOO'. + + endpoint := '/projects/' , projectKey , '/repos'. + + response := { (#repo -> '1') } asDictionary. + + (bitbucketRepos stub getAll: endpoint withParams: Dictionary new) + willReturn: response. + + "When" + result := bitbucketRepos allInProject: projectKey. + + "Then" + self assert: result equals: response +] + { #category : 'tests' } BitbucketRepositoriesTest >> testRawFileWithParamsInRepositoryOfProject [ diff --git a/src/BitbucketPharoAPI/BitbucketRepositories.class.st b/src/BitbucketPharoAPI/BitbucketRepositories.class.st index 92b7941..89567a1 100644 --- a/src/BitbucketPharoAPI/BitbucketRepositories.class.st +++ b/src/BitbucketPharoAPI/BitbucketRepositories.class.st @@ -5,6 +5,15 @@ Class { #package : 'BitbucketPharoAPI' } +{ #category : 'api - get' } +BitbucketRepositories >> allInProject: projectKey [ + "GET /rest/api/1.0/projects/{projectKey}/repos" + | endpoint | + endpoint := '/projects/' , projectKey , '/repos'. + + ^ self getAll: endpoint withParams: Dictionary new +] + { #category : 'api - get' } BitbucketRepositories >> rawFile: filePath withParams: paramsDict inRepository: repositorySlug ofProject: projectKey [ "/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/raw/{path:.*}?at&markup&hardwrap&htmlEscape"