mirror of
https://github.com/gfleury/go-bitbucket-v1.git
synced 2025-04-05 01:10:12 -05:00
Adding mock server for simple projects
This commit is contained in:
parent
aabce9f497
commit
14d4b869a5
@ -505,7 +505,9 @@ func TestDefaultApiService_Create(t *testing.T) {
|
|||||||
t.Errorf("DefaultApiService.Create() error = %v, wantErr %v", err, tt.wantErr)
|
t.Errorf("DefaultApiService.Create() error = %v, wantErr %v", err, tt.wantErr)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
got.Response = nil
|
if got != nil {
|
||||||
|
got.Response = nil
|
||||||
|
}
|
||||||
if !reflect.DeepEqual(got, tt.want) {
|
if !reflect.DeepEqual(got, tt.want) {
|
||||||
t.Errorf("DefaultApiService.Create() = %v, want %v", 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)
|
t.Errorf("DefaultApiService.Create() error = %v, wantErr %v", err, tt.wantErr)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
got.Response = nil
|
if got != nil {
|
||||||
|
got.Response = nil
|
||||||
|
}
|
||||||
if !reflect.DeepEqual(got, tt.want) {
|
if !reflect.DeepEqual(got, tt.want) {
|
||||||
t.Errorf("DefaultApiService.Create() = %v, want %v", 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)
|
t.Errorf("DefaultApiService.Delete() error = %v, wantErr %v", err, tt.wantErr)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
got.Response = nil
|
if got != nil {
|
||||||
|
got.Response = nil
|
||||||
|
}
|
||||||
if !reflect.DeepEqual(got, tt.want) {
|
if !reflect.DeepEqual(got, tt.want) {
|
||||||
t.Errorf("DefaultApiService.Delete() = %v, want %v", 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)
|
t.Errorf("DefaultApiService.GetSSHKeys() error = %v, wantErr %v", err, tt.wantErr)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
got.Response = nil
|
if got != nil {
|
||||||
|
got.Response = nil
|
||||||
|
}
|
||||||
if !reflect.DeepEqual(got, tt.want) {
|
if !reflect.DeepEqual(got, tt.want) {
|
||||||
t.Errorf("DefaultApiService.GetSSHKeys() = %v, want %v", 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)
|
t.Errorf("DefaultApiService.GetUser() error = %v, wantErr %v", err, tt.wantErr)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
got.Response = nil
|
if got != nil {
|
||||||
|
got.Response = nil
|
||||||
|
}
|
||||||
if !reflect.DeepEqual(got, tt.want) {
|
if !reflect.DeepEqual(got, tt.want) {
|
||||||
t.Errorf("DefaultApiService.GetUser() = %v, want %v", got, tt.want)
|
t.Errorf("DefaultApiService.GetUser() = %v, want %v", got, tt.want)
|
||||||
}
|
}
|
||||||
|
5
test/bb-mock-server/go.mod
Normal file
5
test/bb-mock-server/go.mod
Normal 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
|
2
test/bb-mock-server/go.sum
Normal file
2
test/bb-mock-server/go.sum
Normal 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=
|
25
test/bb-mock-server/go/README.md
Normal file
25
test/bb-mock-server/go/README.md
Normal 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
|
||||||
|
```
|
||||||
|
|
5750
test/bb-mock-server/go/api_default.go
Normal file
5750
test/bb-mock-server/go/api_default.go
Normal file
File diff suppressed because it is too large
Load Diff
32
test/bb-mock-server/go/logger.go
Normal file
32
test/bb-mock-server/go/logger.go
Normal 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),
|
||||||
|
)
|
||||||
|
})
|
||||||
|
}
|
15
test/bb-mock-server/go/mockserver.go
Normal file
15
test/bb-mock-server/go/mockserver.go
Normal 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)
|
||||||
|
}
|
1394
test/bb-mock-server/go/routers.go
Normal file
1394
test/bb-mock-server/go/routers.go
Normal file
File diff suppressed because it is too large
Load Diff
1
test/bb-mock-server/mocked_responses/AddGroupToUser.json
Normal file
1
test/bb-mock-server/mocked_responses/AddGroupToUser.json
Normal file
@ -0,0 +1 @@
|
|||||||
|
{}
|
35
test/bb-mock-server/mocked_responses/Create.json
Normal file
35
test/bb-mock-server/mocked_responses/Create.json
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
{
|
||||||
|
"title": "Talking Nerdy",
|
||||||
|
"description": "It’s 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"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
1
test/bb-mock-server/mocked_responses/Delete.json
Normal file
1
test/bb-mock-server/mocked_responses/Delete.json
Normal file
@ -0,0 +1 @@
|
|||||||
|
{}
|
1
test/bb-mock-server/mocked_responses/GetUser.json
Normal file
1
test/bb-mock-server/mocked_responses/GetUser.json
Normal file
@ -0,0 +1 @@
|
|||||||
|
{}
|
20
test/bb-mock-server/mockserver.go
Normal file
20
test/bb-mock-server/mockserver.go
Normal 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))
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user