fix: error occour when the data parent dir non-exist (#291)
This commit is contained in:
parent
0d9b280487
commit
04828b2984
|
@ -28,6 +28,7 @@ import (
|
|||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"os"
|
||||
"strings"
|
||||
"sync"
|
||||
|
@ -228,7 +229,7 @@ func (o *runOption) runSuiteWithDuration(loader testing.Loader) (err error) {
|
|||
defer sem.Release(1)
|
||||
defer wait.Done()
|
||||
defer func() {
|
||||
fmt.Println("routing end with", time.Since(now))
|
||||
log.Println("routing end with", time.Since(now))
|
||||
}()
|
||||
|
||||
dataContext := getDefaultContext()
|
||||
|
|
|
@ -7,6 +7,7 @@ import type { Pair, TestResult, TestCaseWithSuite } from './types'
|
|||
import { NewSuggestedAPIsQuery, CreateFilter, GetHTTPMethods, FlattenObject } from './types'
|
||||
import { Cache } from './cache'
|
||||
import { API } from './net'
|
||||
import { UIAPI } from './net-vue'
|
||||
import type { TestCaseResponse } from './cache'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { JSONPath } from 'jsonpath-plus'
|
||||
|
@ -71,7 +72,7 @@ const sendRequest = async () => {
|
|||
parameters.value = []
|
||||
|
||||
requestLoading.value = false
|
||||
ElMessage.error('Oops, ' + e)
|
||||
UIAPI.ErrorTip(e)
|
||||
testResult.value.bodyObject = JSON.parse(e.body)
|
||||
testResult.value.originBodyObject = JSON.parse(e.body)
|
||||
})
|
||||
|
@ -96,9 +97,7 @@ function openParameterDialog() {
|
|||
API.GetTestSuite(props.suite, (e) => {
|
||||
parameters.value = e.param
|
||||
parameterDialogOpened.value = true
|
||||
}, (e) => {
|
||||
ElMessage.error('Oops, ' + e)
|
||||
})
|
||||
}, UIAPI.ErrorTip)
|
||||
}
|
||||
|
||||
function sendRequestWithParameter() {
|
||||
|
@ -124,9 +123,7 @@ function generateCode() {
|
|||
} else {
|
||||
currentCodeContent.value = e.message
|
||||
}
|
||||
}, (e) => {
|
||||
ElMessage.error('Oops, ' + e)
|
||||
})
|
||||
}, UIAPI.ErrorTip)
|
||||
}
|
||||
|
||||
function copyCode() {
|
||||
|
@ -268,23 +265,14 @@ watch(testCaseWithSuite, (after, before) => {
|
|||
|
||||
const saveLoading = ref(false)
|
||||
function saveTestCase(tip: boolean = true) {
|
||||
saveLoading.value = true
|
||||
|
||||
API.UpdateTestCase(testCaseWithSuite.value, (e) => {
|
||||
UIAPI.UpdateTestCase(testCaseWithSuite.value, (e) => {
|
||||
if (tip) {
|
||||
if (e.ok) {
|
||||
ElMessage({
|
||||
message: 'Saved.',
|
||||
type: 'success'
|
||||
})
|
||||
|
||||
needUpdate.value = false
|
||||
} else {
|
||||
ElMessage.error('Oops, ' + e.statusText)
|
||||
}
|
||||
ElMessage({
|
||||
message: 'Saved.',
|
||||
type: 'success'
|
||||
})
|
||||
}
|
||||
saveLoading.value = false
|
||||
})
|
||||
}, UIAPI.ErrorTip, saveLoading)
|
||||
}
|
||||
|
||||
function deleteTestCase() {
|
||||
|
@ -306,7 +294,7 @@ function deleteTestCase() {
|
|||
// clean all the values
|
||||
testCaseWithSuite.value = emptyTestCaseWithSuite
|
||||
} else {
|
||||
ElMessage.error('Oops, ' + e.statusText)
|
||||
UIAPI.ErrorTip(e)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
/**
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2023 API Testing Authors.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
import { API } from './net'
|
||||
import type { Ref } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
|
||||
function UpdateTestCase(testcase: any,
|
||||
callback: (d: any) => void, errHandle?: (e: any) => void | null,
|
||||
loadingRef?: Ref<Boolean>) {
|
||||
API.UpdateTestCase(testcase, callback, errHandle, (e: boolean) => {
|
||||
if (loadingRef) {
|
||||
loadingRef.value = e
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function ErrorTip(e: {
|
||||
statusText:''
|
||||
}) {
|
||||
ElMessage.error('Oops, ' + e.statusText)
|
||||
}
|
||||
|
||||
export const UIAPI = {
|
||||
UpdateTestCase,
|
||||
ErrorTip
|
||||
}
|
|
@ -40,6 +40,13 @@ interface AppVersion {
|
|||
message: string
|
||||
}
|
||||
|
||||
function safeToggleFunc(toggle?: (e: boolean) => void) {
|
||||
if (!toggle) {
|
||||
return (e: boolean) => {}
|
||||
}
|
||||
return toggle
|
||||
}
|
||||
|
||||
function GetVersion(callback: (v: AppVersion) => void) {
|
||||
const requestOptions = {
|
||||
method: 'POST',
|
||||
|
@ -96,8 +103,8 @@ function UpdateTestSuite(suite: any,
|
|||
.then(callback).catch(errHandle)
|
||||
}
|
||||
|
||||
function GetTestSuite(name: string, callback: () => void,
|
||||
errHandle: (e: any) => void) {
|
||||
function GetTestSuite(name: string,
|
||||
callback: (d: any) => void, errHandle: (e: any) => void) {
|
||||
const store = Cache.GetCurrentStore()
|
||||
const requestOptions = {
|
||||
method: 'POST',
|
||||
|
@ -149,7 +156,7 @@ function ConvertTestSuite(suiteName: string, genertor: string,
|
|||
.then(callback).catch(errHandle)
|
||||
}
|
||||
|
||||
function ImportTestSuite(source: ImportSource, callback: () => void) {
|
||||
function ImportTestSuite(source: ImportSource, callback: (d: any) => void) {
|
||||
const requestOptions = {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
|
@ -174,7 +181,7 @@ interface TestCase {
|
|||
}
|
||||
|
||||
function CreateTestCase(testcase: TestCase,
|
||||
callback: () => {}, errHandle?: (e: any) => void | null) {
|
||||
callback: (d: any) => void, errHandle?: (e: any) => void | null) {
|
||||
const requestOptions = {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
|
@ -199,7 +206,8 @@ function CreateTestCase(testcase: TestCase,
|
|||
}
|
||||
|
||||
function UpdateTestCase(testcase: any,
|
||||
callback: () => {}, errHandle?: (e: any) => void | null) {
|
||||
callback: (d: any) => void, errHandle?: (e: any) => void | null,
|
||||
toggle?: (e: boolean) => void) {
|
||||
const requestOptions = {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
|
@ -208,9 +216,13 @@ function UpdateTestCase(testcase: any,
|
|||
},
|
||||
body: JSON.stringify(testcase)
|
||||
}
|
||||
safeToggleFunc(toggle)(true)
|
||||
fetch('/server.Runner/UpdateTestCase', requestOptions)
|
||||
.then(DefaultResponseProcess)
|
||||
.then(callback).catch(errHandle)
|
||||
.finally(() => {
|
||||
safeToggleFunc(toggle)(false)
|
||||
})
|
||||
}
|
||||
|
||||
function GetTestCase(req: TestCase,
|
||||
|
@ -227,7 +239,7 @@ function GetTestCase(req: TestCase,
|
|||
})
|
||||
}
|
||||
fetch('/server.Runner/GetTestCase', requestOptions)
|
||||
.then((response) => response.json())
|
||||
.then(DefaultResponseProcess)
|
||||
.then(callback).catch(errHandle)
|
||||
}
|
||||
|
||||
|
@ -402,4 +414,4 @@ export const API = {
|
|||
PopularHeaders,
|
||||
GetStores, DeleteStore, VerifyStore,
|
||||
getToken
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package pkg
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
"sync"
|
||||
)
|
||||
|
@ -64,19 +65,19 @@ func (c *Collects) Stop() {
|
|||
}
|
||||
|
||||
func (c *Collects) handleEvents() {
|
||||
fmt.Println("handle events")
|
||||
log.Println("handle events")
|
||||
c.once.Do(func() {
|
||||
go func() {
|
||||
fmt.Println("start handle events")
|
||||
log.Println("start handle events")
|
||||
for {
|
||||
select {
|
||||
case key := <-c.signal:
|
||||
fmt.Println("receive signal", key)
|
||||
log.Println("receive signal", key)
|
||||
for _, e := range c.events {
|
||||
e(c.keys[key])
|
||||
}
|
||||
case <-c.stopSignal:
|
||||
fmt.Println("stop")
|
||||
log.Println("stop")
|
||||
return
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package pkg
|
|||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"strings"
|
||||
|
||||
"github.com/linuxsuren/api-testing/pkg/testing"
|
||||
|
@ -30,7 +31,7 @@ func NewSampleExporter(saveResponseBody bool) *SampleExporter {
|
|||
func (e *SampleExporter) Add(reqAndResp *RequestAndResponse) {
|
||||
r, resp := reqAndResp.Request, reqAndResp.Response
|
||||
|
||||
fmt.Println("receive", r.URL.Path)
|
||||
log.Println("receive", r.URL.Path)
|
||||
req := atestpkg.Request{
|
||||
API: r.URL.String(),
|
||||
Method: r.Method,
|
||||
|
|
|
@ -89,9 +89,11 @@ require (
|
|||
go.uber.org/zap v1.24.0 // indirect
|
||||
golang.org/x/crypto v0.15.0 // indirect
|
||||
golang.org/x/net v0.18.0 // indirect
|
||||
golang.org/x/oauth2 v0.14.0 // indirect
|
||||
golang.org/x/sync v0.3.0 // indirect
|
||||
golang.org/x/sys v0.14.0 // indirect
|
||||
golang.org/x/text v0.14.0 // indirect
|
||||
google.golang.org/appengine v1.6.7 // indirect
|
||||
google.golang.org/genproto v0.0.0-20230526203410-71b5a4ffd15e // indirect
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20230530153820-e85fd2cbaebc // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20230530153820-e85fd2cbaebc // indirect
|
||||
|
|
|
@ -1157,6 +1157,8 @@ golang.org/x/oauth2 v0.0.0-20221014153046-6fdb5e3db783/go.mod h1:h4gKUeWbJ4rQPri
|
|||
golang.org/x/oauth2 v0.5.0/go.mod h1:9/XBHVqLaWO3/BRHs5jbpYCnOZVjj5V0ndyaAM7KB4I=
|
||||
golang.org/x/oauth2 v0.6.0/go.mod h1:ycmewcwgD4Rpr3eZJLSB4Kyyljb3qDh40vJ8STE5HKw=
|
||||
golang.org/x/oauth2 v0.7.0/go.mod h1:hPLQkd9LyjfXTiRohC/41GhcFqxisoUQ99sCUOHO9x4=
|
||||
golang.org/x/oauth2 v0.14.0 h1:P0Vrf/2538nmC0H+pEQ3MNFRRnVR7RlqyVw+bvm26z0=
|
||||
golang.org/x/oauth2 v0.14.0/go.mod h1:lAtNWgaWfL4cm7j2OV8TxGi9Qb7ECORx8DktCY74OwM=
|
||||
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
|
@ -1421,6 +1423,7 @@ google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7
|
|||
google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0=
|
||||
google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
|
||||
google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
|
||||
google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c=
|
||||
google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
|
||||
google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
||||
google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
||||
|
|
|
@ -27,7 +27,7 @@ package pkg
|
|||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"log"
|
||||
"time"
|
||||
|
||||
"github.com/linuxsuren/api-testing/pkg/server"
|
||||
|
@ -291,7 +291,7 @@ func saveTestSuite(ctx context.Context, cli SimpleKV, suite *testing.TestSuite)
|
|||
var data []byte
|
||||
if data, err = testing.ToYAML(suite); err == nil {
|
||||
_, err = cli.Put(ctx, getKey(suite.Name), string(data))
|
||||
fmt.Println("save to etcd", err)
|
||||
log.Println("save to etcd", err)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
|
|
@ -107,10 +107,12 @@ require (
|
|||
golang.org/x/crypto v0.15.0 // indirect
|
||||
golang.org/x/mod v0.12.0 // indirect
|
||||
golang.org/x/net v0.18.0 // indirect
|
||||
golang.org/x/oauth2 v0.14.0 // indirect
|
||||
golang.org/x/sync v0.3.0 // indirect
|
||||
golang.org/x/sys v0.14.0 // indirect
|
||||
golang.org/x/text v0.14.0 // indirect
|
||||
golang.org/x/tools v0.12.0 // indirect
|
||||
google.golang.org/appengine v1.6.7 // indirect
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20230530153820-e85fd2cbaebc // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20230530153820-e85fd2cbaebc // indirect
|
||||
google.golang.org/protobuf v1.31.0 // indirect
|
||||
|
|
|
@ -456,6 +456,8 @@ golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43/go.mod h1:KelEdhl1UZF7XfJ
|
|||
golang.org/x/oauth2 v0.0.0-20201109201403-9fd604954f58/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
|
||||
golang.org/x/oauth2 v0.0.0-20201208152858-08078c50e5b5/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
|
||||
golang.org/x/oauth2 v0.0.0-20210218202405-ba52d332ba99/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
|
||||
golang.org/x/oauth2 v0.14.0 h1:P0Vrf/2538nmC0H+pEQ3MNFRRnVR7RlqyVw+bvm26z0=
|
||||
golang.org/x/oauth2 v0.14.0/go.mod h1:lAtNWgaWfL4cm7j2OV8TxGi9Qb7ECORx8DktCY74OwM=
|
||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
|
@ -620,6 +622,7 @@ google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7
|
|||
google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0=
|
||||
google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
|
||||
google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
|
||||
google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c=
|
||||
google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
|
||||
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
|
||||
google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
||||
|
|
|
@ -29,6 +29,7 @@ import (
|
|||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"os"
|
||||
"path"
|
||||
"time"
|
||||
|
@ -62,7 +63,7 @@ func (s *gitClient) loadCache(ctx context.Context) (opt *gitOptions, err error)
|
|||
branch := "master"
|
||||
repoAddr := opt.cloneOptions.URL
|
||||
configDir := opt.cache
|
||||
fmt.Println("load cache from", repoAddr)
|
||||
log.Println("load cache from", repoAddr)
|
||||
|
||||
if ok, _ := util.PathExists(configDir); ok {
|
||||
var repo *git.Repository
|
||||
|
|
|
@ -84,9 +84,11 @@ require (
|
|||
go.uber.org/zap v1.24.0 // indirect
|
||||
golang.org/x/crypto v0.15.0 // indirect
|
||||
golang.org/x/net v0.18.0 // indirect
|
||||
golang.org/x/oauth2 v0.14.0 // indirect
|
||||
golang.org/x/sync v0.3.0 // indirect
|
||||
golang.org/x/sys v0.14.0 // indirect
|
||||
golang.org/x/text v0.14.0 // indirect
|
||||
google.golang.org/appengine v1.6.7 // indirect
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20230530153820-e85fd2cbaebc // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20230530153820-e85fd2cbaebc // indirect
|
||||
google.golang.org/grpc v1.57.0 // indirect
|
||||
|
|
|
@ -421,6 +421,8 @@ golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43/go.mod h1:KelEdhl1UZF7XfJ
|
|||
golang.org/x/oauth2 v0.0.0-20201109201403-9fd604954f58/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
|
||||
golang.org/x/oauth2 v0.0.0-20201208152858-08078c50e5b5/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
|
||||
golang.org/x/oauth2 v0.0.0-20210218202405-ba52d332ba99/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
|
||||
golang.org/x/oauth2 v0.14.0 h1:P0Vrf/2538nmC0H+pEQ3MNFRRnVR7RlqyVw+bvm26z0=
|
||||
golang.org/x/oauth2 v0.14.0/go.mod h1:lAtNWgaWfL4cm7j2OV8TxGi9Qb7ECORx8DktCY74OwM=
|
||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
|
@ -572,6 +574,7 @@ google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7
|
|||
google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0=
|
||||
google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
|
||||
google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
|
||||
google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c=
|
||||
google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
|
||||
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
|
||||
google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
||||
|
|
|
@ -86,9 +86,11 @@ require (
|
|||
go.uber.org/zap v1.24.0 // indirect
|
||||
golang.org/x/crypto v0.15.0 // indirect
|
||||
golang.org/x/net v0.18.0 // indirect
|
||||
golang.org/x/oauth2 v0.14.0 // indirect
|
||||
golang.org/x/sync v0.3.0 // indirect
|
||||
golang.org/x/sys v0.14.0 // indirect
|
||||
golang.org/x/text v0.14.0 // indirect
|
||||
google.golang.org/appengine v1.6.7 // indirect
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20230530153820-e85fd2cbaebc // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20230530153820-e85fd2cbaebc // indirect
|
||||
google.golang.org/grpc v1.57.0 // indirect
|
||||
|
|
|
@ -413,6 +413,8 @@ golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43/go.mod h1:KelEdhl1UZF7XfJ
|
|||
golang.org/x/oauth2 v0.0.0-20201109201403-9fd604954f58/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
|
||||
golang.org/x/oauth2 v0.0.0-20201208152858-08078c50e5b5/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
|
||||
golang.org/x/oauth2 v0.0.0-20210218202405-ba52d332ba99/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
|
||||
golang.org/x/oauth2 v0.14.0 h1:P0Vrf/2538nmC0H+pEQ3MNFRRnVR7RlqyVw+bvm26z0=
|
||||
golang.org/x/oauth2 v0.14.0/go.mod h1:lAtNWgaWfL4cm7j2OV8TxGi9Qb7ECORx8DktCY74OwM=
|
||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
|
@ -562,6 +564,7 @@ google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7
|
|||
google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0=
|
||||
google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
|
||||
google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
|
||||
google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c=
|
||||
google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
|
||||
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
|
||||
google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
||||
|
|
|
@ -84,9 +84,11 @@ require (
|
|||
go.uber.org/zap v1.24.0 // indirect
|
||||
golang.org/x/crypto v0.15.0 // indirect
|
||||
golang.org/x/net v0.18.0 // indirect
|
||||
golang.org/x/oauth2 v0.14.0 // indirect
|
||||
golang.org/x/sync v0.3.0 // indirect
|
||||
golang.org/x/sys v0.14.0 // indirect
|
||||
golang.org/x/text v0.14.0 // indirect
|
||||
google.golang.org/appengine v1.6.7 // indirect
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20230822172742-b8732ec3820d // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d // indirect
|
||||
google.golang.org/grpc v1.59.0 // indirect
|
||||
|
|
|
@ -414,6 +414,8 @@ golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43/go.mod h1:KelEdhl1UZF7XfJ
|
|||
golang.org/x/oauth2 v0.0.0-20201109201403-9fd604954f58/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
|
||||
golang.org/x/oauth2 v0.0.0-20201208152858-08078c50e5b5/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
|
||||
golang.org/x/oauth2 v0.0.0-20210218202405-ba52d332ba99/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
|
||||
golang.org/x/oauth2 v0.14.0 h1:P0Vrf/2538nmC0H+pEQ3MNFRRnVR7RlqyVw+bvm26z0=
|
||||
golang.org/x/oauth2 v0.14.0/go.mod h1:lAtNWgaWfL4cm7j2OV8TxGi9Qb7ECORx8DktCY74OwM=
|
||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
|
@ -565,6 +567,7 @@ google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7
|
|||
google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0=
|
||||
google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
|
||||
google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
|
||||
google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c=
|
||||
google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
|
||||
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
|
||||
google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
||||
|
|
|
@ -26,7 +26,7 @@ package generator
|
|||
|
||||
import (
|
||||
"encoding/xml"
|
||||
"fmt"
|
||||
"log"
|
||||
"net/url"
|
||||
|
||||
"github.com/linuxsuren/api-testing/pkg/testing"
|
||||
|
@ -60,7 +60,7 @@ func (c *jmeterConverter) buildJmeterTestPlan(testSuite *testing.TestSuite) (res
|
|||
for _, item := range testSuite.Items {
|
||||
item.Request.RenderAPI(testSuite.API)
|
||||
if reqRenderErr := item.Request.Render(emptyCtx, ""); reqRenderErr != nil {
|
||||
fmt.Println("Error rendering request: ", reqRenderErr)
|
||||
log.Println("Error rendering request: ", reqRenderErr)
|
||||
}
|
||||
|
||||
api, err := url.Parse(item.Request.API)
|
||||
|
|
|
@ -314,7 +314,7 @@ func getMethodDescriptor(ctx context.Context, r *gRPCTestCaseRunner, testcase *t
|
|||
|
||||
var dp protoreflect.Descriptor
|
||||
// if fd, ok := r.fdCache.Load(fullname.Parent()); ok {
|
||||
// fmt.Println("hit cache",fullname)
|
||||
// log.Println("hit cache",fullname)
|
||||
// return getMdFromFd(fd.(protoreflect.FileDescriptor), fullname)
|
||||
// }
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ import (
|
|||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
"strings"
|
||||
|
@ -85,7 +86,7 @@ type defaultResourceValidator struct {
|
|||
// Exist returns true if the specific resource exist
|
||||
func (v *defaultResourceValidator) Exist() bool {
|
||||
if v.err != nil {
|
||||
fmt.Println(v.err)
|
||||
log.Println(v.err)
|
||||
return false
|
||||
}
|
||||
return v.data != nil && len(v.data) > 0
|
||||
|
|
|
@ -25,7 +25,7 @@ SOFTWARE.
|
|||
package runner
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"sync"
|
||||
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
|
@ -91,7 +91,7 @@ func (w *prometheusReporter) PutRecord(record *ReportRecord) {
|
|||
}
|
||||
|
||||
if err := pusher.Push(); err != nil {
|
||||
fmt.Println("Could not push completion time to Pushgateway:", err)
|
||||
log.Println("Could not push completion time to Pushgateway:", err)
|
||||
}
|
||||
}()
|
||||
if w.sync {
|
||||
|
|
|
@ -21,7 +21,7 @@ SOFTWARE.
|
|||
package runner
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"strings"
|
||||
|
||||
"github.com/linuxsuren/api-testing/pkg/testing"
|
||||
|
@ -40,7 +40,7 @@ func GetTestSuiteRunner(suite *testing.TestSuite) TestCaseRunner {
|
|||
case "trpc":
|
||||
return NewTRPCTestCaseRunner(suite.API, *suite.Spec.RPC, client.New())
|
||||
default:
|
||||
fmt.Println("unknown test suite, try to use HTTP runner")
|
||||
log.Println("unknown test suite, try to use HTTP runner")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ func (w *pdfResultWriter) Output(result []ReportResult) (err error) {
|
|||
|
||||
pdf := gopdf.GoPdf{}
|
||||
pdf.Start(gopdf.Config{PageSize: *gopdf.PageSizeA4})
|
||||
fmt.Println(findfont.List()[len(findfont.List())-1])
|
||||
log.Println(findfont.List()[len(findfont.List())-1])
|
||||
fontPath, err := findfont.Find("DejaVuSerif.ttf")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
|
|
@ -1,3 +1,27 @@
|
|||
/**
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2023 API Testing Authors.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
package testing
|
||||
|
||||
import "sort"
|
||||
|
|
|
@ -1,3 +1,27 @@
|
|||
/**
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2023 API Testing Authors.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
package testing
|
||||
|
||||
// Loader is an interface for test cases loader
|
||||
|
|
|
@ -1,3 +1,27 @@
|
|||
/**
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2023 API Testing Authors.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
package testing
|
||||
|
||||
import (
|
||||
|
@ -117,7 +141,7 @@ func (l *fileLoader) Put(item string) (err error) {
|
|||
if files, err = filepath.Glob(pattern); err == nil {
|
||||
l.paths = append(l.paths, files...)
|
||||
}
|
||||
fmt.Println(pattern, "pattern", len(files))
|
||||
log.Println(pattern, "pattern", len(files))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
@ -189,9 +213,15 @@ func (l *fileLoader) CreateSuite(name, api string) (err error) {
|
|||
if l.parent == "" {
|
||||
l.parent = path.Dir(absPath)
|
||||
}
|
||||
|
||||
if err = os.MkdirAll(l.parent, 0755); err != nil {
|
||||
err = fmt.Errorf("failed to create %q", l.parent)
|
||||
return
|
||||
}
|
||||
|
||||
newSuiteFile := path.Join(l.parent, fmt.Sprintf("%s.yaml", name))
|
||||
if newSuiteFile, err = filepath.Abs(newSuiteFile); err == nil {
|
||||
fmt.Println("new suite file:", newSuiteFile)
|
||||
log.Println("new suite file:", newSuiteFile)
|
||||
|
||||
suite := &TestSuite{
|
||||
Name: name,
|
||||
|
|
|
@ -1,3 +1,27 @@
|
|||
/**
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2023 API Testing Authors.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
package testing_test
|
||||
|
||||
import (
|
||||
|
|
Loading…
Reference in New Issue