mirror of https://github.com/statping/statping
export HTTP test
parent
a3ce4124f6
commit
79918d025d
|
@ -8,7 +8,7 @@ const tokenKey = "statping_auth";
|
||||||
class Api {
|
class Api {
|
||||||
constructor() {
|
constructor() {
|
||||||
this.version = "0.90.66";
|
this.version = "0.90.66";
|
||||||
this.commit = "eb9792d18480736630f4811caf56add31b78c3c2";
|
this.commit = "a3ce4124f654b13c7f2af88b8410f998bd57fcef";
|
||||||
}
|
}
|
||||||
|
|
||||||
async oauth() {
|
async oauth() {
|
||||||
|
|
|
@ -2275,7 +2275,7 @@ OluFxewsEO0QNDrfFb+0gnjYlnGqOFcZjUMXbDdY5oLSPtXohynuTK1qyQ==
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="text-center small text-dim" v-pre>
|
<div class="text-center small text-dim" v-pre>
|
||||||
Automatically generated from Statping's Wiki on 2020-09-09 00:56:11.888825 +0000 UTC
|
Automatically generated from Statping's Wiki on 2020-09-09 01:24:21.649582 +0000 UTC
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -9,12 +9,15 @@ import (
|
||||||
_ "github.com/statping/statping/notifiers"
|
_ "github.com/statping/statping/notifiers"
|
||||||
"github.com/statping/statping/source"
|
"github.com/statping/statping/source"
|
||||||
"github.com/statping/statping/types"
|
"github.com/statping/statping/types"
|
||||||
|
"github.com/statping/statping/types/checkins"
|
||||||
"github.com/statping/statping/types/core"
|
"github.com/statping/statping/types/core"
|
||||||
"github.com/statping/statping/types/groups"
|
"github.com/statping/statping/types/groups"
|
||||||
|
"github.com/statping/statping/types/messages"
|
||||||
"github.com/statping/statping/types/services"
|
"github.com/statping/statping/types/services"
|
||||||
"github.com/statping/statping/types/users"
|
"github.com/statping/statping/types/users"
|
||||||
"github.com/statping/statping/utils"
|
"github.com/statping/statping/utils"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
|
@ -254,6 +257,26 @@ func TestMainApiRoutes(t *testing.T) {
|
||||||
Method: "GET",
|
Method: "GET",
|
||||||
ExpectedStatus: 200,
|
ExpectedStatus: 200,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Name: "Export Settings",
|
||||||
|
URL: "/api/settings/export",
|
||||||
|
Method: "GET",
|
||||||
|
ExpectedStatus: 200,
|
||||||
|
BeforeTest: SetTestENV,
|
||||||
|
AfterTest: UnsetTestENV,
|
||||||
|
ResponseFunc: func(r *httptest.ResponseRecorder, t *testing.T, bytes []byte) error {
|
||||||
|
var data ExportData
|
||||||
|
err := json.Unmarshal(r.Body.Bytes(), &data)
|
||||||
|
require.Nil(t, err)
|
||||||
|
assert.Len(t, data.Services, len(services.All()))
|
||||||
|
assert.Len(t, data.Groups, len(groups.All()))
|
||||||
|
assert.Len(t, data.Notifiers, len(services.AllNotifiers()))
|
||||||
|
assert.Len(t, data.Users, len(users.All()))
|
||||||
|
assert.Len(t, data.Messages, len(messages.All()))
|
||||||
|
assert.Len(t, data.Checkins, len(checkins.All()))
|
||||||
|
return nil
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, v := range tests {
|
for _, v := range tests {
|
||||||
|
|
|
@ -218,6 +218,7 @@ func settingsImportHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
if exportData.Groups != nil {
|
if exportData.Groups != nil {
|
||||||
for _, s := range exportData.Groups {
|
for _, s := range exportData.Groups {
|
||||||
|
s.Id = 0
|
||||||
if err := s.Create(); err != nil {
|
if err := s.Create(); err != nil {
|
||||||
sendErrorJson(err, w, r)
|
sendErrorJson(err, w, r)
|
||||||
return
|
return
|
||||||
|
@ -227,6 +228,7 @@ func settingsImportHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
if exportData.Services != nil {
|
if exportData.Services != nil {
|
||||||
for _, s := range exportData.Services {
|
for _, s := range exportData.Services {
|
||||||
|
s.Id = 0
|
||||||
if err := s.Create(); err != nil {
|
if err := s.Create(); err != nil {
|
||||||
sendErrorJson(err, w, r)
|
sendErrorJson(err, w, r)
|
||||||
return
|
return
|
||||||
|
@ -236,6 +238,7 @@ func settingsImportHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
if exportData.Users != nil {
|
if exportData.Users != nil {
|
||||||
for _, s := range exportData.Users {
|
for _, s := range exportData.Users {
|
||||||
|
s.Id = 0
|
||||||
if err := s.Create(); err != nil {
|
if err := s.Create(); err != nil {
|
||||||
sendErrorJson(err, w, r)
|
sendErrorJson(err, w, r)
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in New Issue