mirror of
https://github.com/gfleury/go-bitbucket-v1.git
synced 2025-04-04 17:00:12 -05:00
Adding build-status endpoints and test coverage
This commit is contained in:
parent
ffb767fdb8
commit
aabce9f497
@ -16,10 +16,10 @@ before_install:
|
||||
- docker ps -a
|
||||
- curl http://localhost:7990/mvc/login?nextUrl=/dashboard |grep "Log in"; while [ $? != 0 ]; do sleep 2; curl http://localhost:7990/mvc/login?nextUrl=/dashboard |grep "Log in"; done
|
||||
|
||||
|
||||
script:
|
||||
- go test
|
||||
- go test -coverprofile=coverage.txt -covermode=atomic
|
||||
- INTEGRATION=TRUE go test
|
||||
- go build -v ./
|
||||
- if [[ "$(go version)" =~ "go version go1.11" ]]; then exit 0; else go get -u github.com/golangci/golangci-lint/cmd/golangci-lint && golangci-lint run -v; fi
|
||||
|
||||
after_success:
|
||||
- bash <(curl -s https://codecov.io/bash)
|
||||
|
629
default_api.go
629
default_api.go
File diff suppressed because it is too large
Load Diff
@ -1998,7 +1998,7 @@ func TestDefaultApiService_Get(t *testing.T) {
|
||||
a := &DefaultApiService{
|
||||
client: tt.fields.client,
|
||||
}
|
||||
got, err := a.Get()
|
||||
got, err := a.GetLicense()
|
||||
if (err != nil) != tt.wantErr {
|
||||
t.Errorf("DefaultApiService.Get() error = %v, wantErr %v", err, tt.wantErr)
|
||||
return
|
||||
@ -7401,6 +7401,7 @@ func TestDefaultApiService_UpdateStatus(t *testing.T) {
|
||||
repositorySlug string
|
||||
pullRequestID int64
|
||||
userSlug string
|
||||
participant UserWithMetadata
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
@ -7419,7 +7420,7 @@ func TestDefaultApiService_UpdateStatus(t *testing.T) {
|
||||
a := &DefaultApiService{
|
||||
client: tt.fields.client,
|
||||
}
|
||||
got, err := a.UpdateStatus(tt.args.projectKey, tt.args.repositorySlug, tt.args.pullRequestID, tt.args.userSlug)
|
||||
got, err := a.UpdateStatus(tt.args.projectKey, tt.args.repositorySlug, tt.args.pullRequestID, tt.args.userSlug, tt.args.participant)
|
||||
if (err != nil) != tt.wantErr {
|
||||
t.Errorf("DefaultApiService.UpdateStatus() error = %v, wantErr %v", err, tt.wantErr)
|
||||
return
|
||||
@ -7870,3 +7871,148 @@ func TestDefaultApiService_WithdrawApproval(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestDefaultApiService_GetCommitStats(t *testing.T) {
|
||||
type fields struct {
|
||||
client *APIClient
|
||||
}
|
||||
type args struct {
|
||||
commitID string
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
fields fields
|
||||
args args
|
||||
want *APIResponse
|
||||
wantErr, integrationTest bool
|
||||
}{
|
||||
{"networkErrorContextExceeded", fields{client: generateConfigFake()}, args{}, &APIResponse{Message: "Get https://stash.domain.com/rest/build-status/1.0/commits/stats/: context canceled"}, true, false},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
if tt.integrationTest != runIntegrationTests {
|
||||
continue
|
||||
}
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
a := &DefaultApiService{
|
||||
client: tt.fields.client,
|
||||
}
|
||||
got, err := a.GetCommitStats(tt.args.commitID)
|
||||
if (err != nil) != tt.wantErr {
|
||||
t.Errorf("DefaultApiService.WithdrawApproval() error = %v, wantErr %v", err, tt.wantErr)
|
||||
return
|
||||
}
|
||||
if !reflect.DeepEqual(got, tt.want) {
|
||||
t.Errorf("DefaultApiService.WithdrawApproval() = %v, want %v", got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestDefaultApiService_GetCommitStatus(t *testing.T) {
|
||||
type fields struct {
|
||||
client *APIClient
|
||||
}
|
||||
type args struct {
|
||||
commitID string
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
fields fields
|
||||
args args
|
||||
want *APIResponse
|
||||
wantErr, integrationTest bool
|
||||
}{
|
||||
{"networkErrorContextExceeded", fields{client: generateConfigFake()}, args{}, &APIResponse{Message: "Get https://stash.domain.com/rest/rest/build-status/1.0/commits/: context canceled"}, true, false},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
if tt.integrationTest != runIntegrationTests {
|
||||
continue
|
||||
}
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
a := &DefaultApiService{
|
||||
client: tt.fields.client,
|
||||
}
|
||||
got, err := a.GetCommitStatus(tt.args.commitID)
|
||||
if (err != nil) != tt.wantErr {
|
||||
t.Errorf("DefaultApiService.WithdrawApproval() error = %v, wantErr %v", err, tt.wantErr)
|
||||
return
|
||||
}
|
||||
if !reflect.DeepEqual(got, tt.want) {
|
||||
t.Errorf("DefaultApiService.WithdrawApproval() = %v, want %v", got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestDefaultApiService_GetCommitsStats(t *testing.T) {
|
||||
type fields struct {
|
||||
client *APIClient
|
||||
}
|
||||
type args struct {
|
||||
commitsID []string
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
fields fields
|
||||
args args
|
||||
want *APIResponse
|
||||
wantErr, integrationTest bool
|
||||
}{
|
||||
{"networkErrorContextExceeded", fields{client: generateConfigFake()}, args{}, &APIResponse{Message: "Post https://stash.domain.com/rest/build-status/1.0/commits/stats: context canceled"}, true, false},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
if tt.integrationTest != runIntegrationTests {
|
||||
continue
|
||||
}
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
a := &DefaultApiService{
|
||||
client: tt.fields.client,
|
||||
}
|
||||
got, err := a.GetCommitsStats(tt.args.commitsID)
|
||||
if (err != nil) != tt.wantErr {
|
||||
t.Errorf("DefaultApiService.WithdrawApproval() error = %v, wantErr %v", err, tt.wantErr)
|
||||
return
|
||||
}
|
||||
if !reflect.DeepEqual(got, tt.want) {
|
||||
t.Errorf("DefaultApiService.WithdrawApproval() = %v, want %v", got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestDefaultApiService_SetCommitStatus(t *testing.T) {
|
||||
type fields struct {
|
||||
client *APIClient
|
||||
}
|
||||
type args struct {
|
||||
commitID string
|
||||
buildStatus BuildStatus
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
fields fields
|
||||
args args
|
||||
want *APIResponse
|
||||
wantErr, integrationTest bool
|
||||
}{
|
||||
{"networkErrorContextExceeded", fields{client: generateConfigFake()}, args{}, &APIResponse{Message: "Post https://stash.domain.com/rest/rest/build-status/1.0/commits/: context canceled"}, true, false},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
if tt.integrationTest != runIntegrationTests {
|
||||
continue
|
||||
}
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
a := &DefaultApiService{
|
||||
client: tt.fields.client,
|
||||
}
|
||||
got, err := a.SetCommitStatus(tt.args.commitID, tt.args.buildStatus)
|
||||
if (err != nil) != tt.wantErr {
|
||||
t.Errorf("DefaultApiService.WithdrawApproval() error = %v, wantErr %v", err, tt.wantErr)
|
||||
return
|
||||
}
|
||||
if !reflect.DeepEqual(got, tt.want) {
|
||||
t.Errorf("DefaultApiService.WithdrawApproval() = %v, want %v", got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
88
docs/bitbucketV1-build-status-swagger.yaml
Normal file
88
docs/bitbucketV1-build-status-swagger.yaml
Normal file
@ -0,0 +1,88 @@
|
||||
swagger: "2.0"
|
||||
host: example.com
|
||||
info:
|
||||
title: Bitbucket Server build-status API
|
||||
description: Bitbucket Server build-status API (former stash).
|
||||
version: 1.0.0
|
||||
basePath: /rest/
|
||||
schemes:
|
||||
- http
|
||||
- https
|
||||
paths:
|
||||
"/build-status/1.0/commits/stats":
|
||||
parameters: []
|
||||
post:
|
||||
parameters:
|
||||
- description: Array of commits.
|
||||
in: body
|
||||
name: commits
|
||||
required: true
|
||||
schema:
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
responses:
|
||||
"200":
|
||||
description: Successful Response
|
||||
description: |-
|
||||
Produces a list of the build statistics for multiple commits.
|
||||
Commits without any builds associated with them will not be returned.
|
||||
For example if the commit e00cf62997a027bbf785614a93e2e55bb331d268 does not have any build statuses associated with it, it will not be present in the response.
|
||||
operationId: GetCommitsStats
|
||||
"/build-status/1.0/commits/stats/{commitId}":
|
||||
parameters:
|
||||
- description: the commit Id
|
||||
in: path
|
||||
name: commitId
|
||||
required: true
|
||||
type: string
|
||||
get:
|
||||
responses:
|
||||
"200":
|
||||
description: Successful Response
|
||||
description: |-
|
||||
Gets statistics regarding the builds associated with a commit.
|
||||
operationId: GetCommitStats
|
||||
"/rest/build-status/1.0/commits/{commitId}":
|
||||
parameters:
|
||||
- description: the commit Id
|
||||
in: path
|
||||
name: commitId
|
||||
required: true
|
||||
type: string
|
||||
get:
|
||||
responses:
|
||||
"200":
|
||||
description: Successful Response
|
||||
description: |-
|
||||
Gets the build statuses associated with a commit.
|
||||
operationId: GetCommitStatus
|
||||
post:
|
||||
parameters:
|
||||
- description: Array of commits.
|
||||
in: body
|
||||
name: buildStatus
|
||||
required: true
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
state:
|
||||
type: string
|
||||
key:
|
||||
type: string
|
||||
name:
|
||||
type: string
|
||||
url:
|
||||
type: string
|
||||
description:
|
||||
type: string
|
||||
responses:
|
||||
"200":
|
||||
description: Successful Response
|
||||
description: |-
|
||||
Associates a build status with a commit.
|
||||
The state, the key and the url are mandatory. The name and description fields are optional.
|
||||
All fields (mandatory or optional) are limited to 255 characters, except for the url, which is limited to 450 characters.
|
||||
Supported values for the state are SUCCESSFUL, FAILED and INPROGRESS.
|
||||
The authenticated user must have LICENSED permission or higher to call this resource.
|
||||
operationId: SetCommitStatus
|
Loading…
x
Reference in New Issue
Block a user