test: fix dredd tests

This commit is contained in:
Denis Gukov 2020-10-03 01:10:41 +05:00
parent c12c490b5c
commit 221f8db31c
3 changed files with 28 additions and 12 deletions

View File

@ -50,12 +50,35 @@ definitions:
name:
type: string
x-example: Integration Test User
example: Integration Test User
username:
type: string
x-example: test-user
example: test-user
email:
type: string
x-example: test@ansiblesemaphore.test
example: test@ansiblesemaphore.test
alert:
type: boolean
admin:
type: boolean
UserPutRequest:
type: object
properties:
name:
type: string
x-example: Integration Test User2
example: Integration Test User2
username:
type: string
x-example: test-user2
example: test-user2
email:
type: string
x-example: test2@ansiblesemaphore.test
example: test2@ansiblesemaphore.test
alert:
type: boolean
admin:
@ -131,6 +154,7 @@ definitions:
type: string
secret:
type: string
example: test
AccessKey:
type: object
properties:
@ -618,7 +642,7 @@ paths:
in: body
required: true
schema:
$ref: "#/definitions/UserRequest"
$ref: "#/definitions/UserPutRequest"
responses:
204:
description: User Updated

View File

@ -7,20 +7,10 @@ import (
"os"
"testing"
"github.com/ansible-semaphore/semaphore/util"
"github.com/go-openapi/loads"
"github.com/go-openapi/spec"
)
func mockParam(w http.ResponseWriter, r *http.Request) {
_, err := util.GetIntParam("test_id", w, r)
if err != nil {
return
}
w.WriteHeader(200)
}
func TestApiPing(t *testing.T) {
req, _ := http.NewRequest("GET", "/api/ping", nil)
rr := httptest.NewRecorder()

View File

@ -102,7 +102,9 @@ func updateUser(w http.ResponseWriter, r *http.Request) {
}
if _, err := db.Mysql.Exec("update user set name=?, username=?, email=?, alert=?, admin=? where id=?", user.Name, user.Username, user.Email, user.Alert, user.Admin, oldUser.ID); err != nil {
panic(err)
log.Error(err.Error())
w.WriteHeader(http.StatusBadRequest)
return
}
w.WriteHeader(http.StatusNoContent)