Merge pull request #54 from gfleury/MockServer

Mock server
This commit is contained in:
George Fleury 2020-03-18 16:59:12 -03:00 committed by GitHub
commit d6c940c167
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 7303 additions and 5 deletions

View File

@ -449,6 +449,13 @@ func GetSSHKeysResponse(r *APIResponse) ([]SSHKey, error) {
return m, err
}
// GetBuildStatusResponse cast BuildStatus into structure
func GetBuildStatusesResponse(r *APIResponse) ([]BuildStatus, error) {
var m []BuildStatus
err := mapstructure.Decode(r.Values["values"], &m)
return m, err
}
// GetPullRequestResponse cast PullRequest into structure
func GetPullRequestResponse(r *APIResponse) (PullRequest, error) {
var m PullRequest

View File

@ -505,7 +505,9 @@ func TestDefaultApiService_Create(t *testing.T) {
t.Errorf("DefaultApiService.Create() error = %v, wantErr %v", err, tt.wantErr)
return
}
got.Response = nil
if got != nil {
got.Response = nil
}
if !reflect.DeepEqual(got, tt.want) {
t.Errorf("DefaultApiService.Create() = %v, want %v", got, tt.want)
}
@ -604,7 +606,9 @@ func TestDefaultApiService_CreatePullRequest(t *testing.T) {
t.Errorf("DefaultApiService.Create() error = %v, wantErr %v", err, tt.wantErr)
return
}
got.Response = nil
if got != nil {
got.Response = nil
}
if !reflect.DeepEqual(got, tt.want) {
t.Errorf("DefaultApiService.Create() = %v, want %v", got, tt.want)
}
@ -1147,7 +1151,9 @@ func TestDefaultApiService_Delete(t *testing.T) {
t.Errorf("DefaultApiService.Delete() error = %v, wantErr %v", err, tt.wantErr)
return
}
got.Response = nil
if got != nil {
got.Response = nil
}
if !reflect.DeepEqual(got, tt.want) {
t.Errorf("DefaultApiService.Delete() = %v, want %v", got, tt.want)
}
@ -4665,7 +4671,9 @@ func TestDefaultApiService_GetSSHKeys(t *testing.T) {
t.Errorf("DefaultApiService.GetSSHKeys() error = %v, wantErr %v", err, tt.wantErr)
return
}
got.Response = nil
if got != nil {
got.Response = nil
}
if !reflect.DeepEqual(got, tt.want) {
t.Errorf("DefaultApiService.GetSSHKeys() = %v, want %v", got, tt.want)
}
@ -4753,7 +4761,9 @@ func TestDefaultApiService_GetUser(t *testing.T) {
t.Errorf("DefaultApiService.GetUser() error = %v, wantErr %v", err, tt.wantErr)
return
}
got.Response = nil
if got != nil {
got.Response = nil
}
if !reflect.DeepEqual(got, tt.want) {
t.Errorf("DefaultApiService.GetUser() = %v, want %v", got, tt.want)
}

View File

@ -0,0 +1,5 @@
module github.com/gfleury/go-bitbucket-v1/test/bb-mock-server
go 1.14
require github.com/gorilla/mux v1.7.4

View File

@ -0,0 +1,2 @@
github.com/gorilla/mux v1.7.4 h1:VuZ8uybHlWmqV03+zRzdwKL4tUnIp1MAQtp1mIFE1bc=
github.com/gorilla/mux v1.7.4/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So=

View File

@ -0,0 +1,25 @@
# Go API Server for swagger
Bitbucket Server API (former stash).
## Overview
This server was generated by the [swagger-codegen]
(https://github.com/swagger-api/swagger-codegen) project.
By using the [OpenAPI-Spec](https://github.com/OAI/OpenAPI-Specification) from a remote server, you can easily generate a server stub.
-
To see how to make this your own, look here:
[README](https://github.com/swagger-api/swagger-codegen/blob/master/README.md)
- API version: 1.0.0
- Build date: 2020-03-18T00:40:49.792Z
### Running the server
To run the server, follow these simple steps:
```
go run main.go
```

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,32 @@
/*
* Bitbucket Server API
*
* Bitbucket Server API (former stash).
*
* API version: 1.0.0
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/
package swagger
import (
"log"
"net/http"
"time"
)
func Logger(inner http.Handler, name string) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
start := time.Now()
inner.ServeHTTP(w, r)
log.Printf(
"%s %s %s %s",
r.Method,
r.RequestURI,
name,
time.Since(start),
)
})
}

View File

@ -0,0 +1,15 @@
package swagger
import (
"fmt"
"log"
"net/http"
)
func RunServer(port int) error {
log.Printf("Mock Server started")
router := NewRouter()
return http.ListenAndServe(fmt.Sprintf(":%d", port), router)
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1 @@
{}

View File

@ -0,0 +1,35 @@
{
"title": "Talking Nerdy",
"description": "Its a kludge, but put the tuple from the database in the cache.",
"state": "OPEN",
"open": true,
"closed": false,
"fromRef": {
"id": "refs/heads/feature-ABC-123",
"repository": {
"slug": "my-repo",
"name": null,
"project": {
"key": "PRJ"
}
}
},
"toRef": {
"id": "refs/heads/master",
"repository": {
"slug": "my-repo",
"name": null,
"project": {
"key": "PRJ"
}
}
},
"locked": false,
"reviewers": [
{
"user": {
"name": "charlie"
}
}
]
}

View File

@ -0,0 +1 @@
{}

View File

@ -0,0 +1 @@
{}

View File

@ -0,0 +1,20 @@
/*
* Bitbucket Server API
*
* Bitbucket Server API (former stash).
*
* API version: 1.0.0
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/
package main
import (
"log"
sw "github.com/gfleury/go-bitbucket-v1/test/bb-mock-server/go"
)
func main() {
log.Fatal(sw.RunServer(7991))
}