Documentation ¶
Overview ¶
Copyright 2023 API Testing Authors.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Package testing provide the test case functions ¶
Copyright 2023 API Testing Authors.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2023-2024 API Testing Authors.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2023 API Testing Authors.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2023 API Testing Authors.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- Constants
- func GetHeader() string
- func SaveTestSuiteToFile(suite *TestSuite, suitePath string) (err error)
- func ToYAML(suite *TestSuite) ([]byte, error)
- type APISpec
- type ConditionalVerify
- type GraphQLRequestBody
- type HistoryTestCase
- type HistoryTestResult
- type HistoryTestSuite
- type Job
- type Loader
- type Metric
- type RPCDesc
- type Request
- type RequestBody
- type Response
- type Secure
- type SortedKeysStringMap
- type Store
- type StoreConfig
- type StoreGetterAndSetter
- type StoreKind
- type StoreWriterFactory
- type TestCase
- type TestCaseResult
- type TestResult
- type TestSuite
- type Verifier
- type Writer
Constants ¶
const (
ContextKeyGlobalParam = "param"
)
Variables ¶
This section is empty.
Functions ¶
func GetHeader ¶ added in v0.0.13
func GetHeader() string
GetHeader returns the header of the YAML config file
func SaveTestSuiteToFile ¶ added in v0.0.13
SaveTestSuiteToFile saves the test suite to file
Types ¶
type APISpec ¶ added in v0.0.13
type APISpec struct { Kind string `yaml:"kind,omitempty" json:"kind,omitempty"` URL string `yaml:"url,omitempty" json:"url,omitempty"` RPC *RPCDesc `yaml:"rpc,omitempty" json:"rpc,omitempty"` Secure *Secure `yaml:"secure,omitempty" json:"secure,omitempty"` Metric *Metric `yaml:"metric,omitempty" json:"metric,omitempty"` }
type ConditionalVerify ¶ added in v0.0.14
type GraphQLRequestBody ¶ added in v0.0.16
type HistoryTestCase ¶ added in v0.0.18
type HistoryTestCase struct { ID string `yaml:"id,omitempty" json:"id,omitempty"` CaseName string `yaml:"caseName,omitempty" json:"name,omitempty"` SuiteName string `yaml:"suiteName,omitempty" json:"suiteName,omitempty"` HistorySuiteName string `yaml:"historySuiteName,omitempty" json:"historySuiteName,omitempty"` CreateTime time.Time `yaml:"createTime,omitempty" json:"createTime,omitempty"` SuiteAPI string `yaml:"api,omitempty" json:"api,omitempty"` SuiteSpec APISpec `yaml:"spec,omitempty" json:"spec,omitempty"` SuiteParam map[string]string `yaml:"param,omitempty" json:"param,omitempty"` Data TestCase `yaml:"data,omitempty" json:"data,omitempty"` HistoryHeader map[string]string `yaml:"historyHeader,omitempty" json:"historyHeader,omitempty"` }
type HistoryTestResult ¶ added in v0.0.18
type HistoryTestResult struct { Message string `yaml:"message,omitempty" json:"message,omitempty"` Error string `yaml:"error,omitempty" json:"error,omitempty"` TestCaseResult []TestCaseResult `yaml:"testCaseResult,omitempty" json:"testCaseResult,omitempty"` Data HistoryTestCase `yaml:"data,omitempty" json:"data,omitempty"` CreateTime time.Time `yaml:"createTime,omitempty" json:"createTime,omitempty"` }
type HistoryTestSuite ¶ added in v0.0.18
type HistoryTestSuite struct { HistorySuiteName string `yaml:"name,omitempty" json:"name,omitempty"` Items []HistoryTestCase `yaml:"items,omitempty" json:"items,omitempty"` }
type Job ¶ added in v0.0.12
type Job struct {
Items []string `yaml:"items,omitempty" json:"items,omitempty"`
}
Job contains a list of jobs
type Loader ¶ added in v0.0.12
type Loader interface { HasMore() bool Load() ([]byte, error) Put(string) (err error) GetContext() string GetCount() int Reset() Verify() (readOnly bool, err error) PProf(name string) []byte }
Loader is an interface for test cases loader
func NewFileLoader ¶ added in v0.0.12
func NewFileLoader() Loader
NewFileLoader creates the instance of file loader
type RPCDesc ¶ added in v0.0.14
type RPCDesc struct { ImportPath []string `yaml:"import,omitempty" json:"import,omitempty"` ServerReflection bool `yaml:"serverReflection,omitempty" json:"serverReflection,omitempty"` ProtoFile string `yaml:"protofile,omitempty" json:"protofile,omitempty"` ProtoSet string `yaml:"protoset,omitempty" json:"protoset,omitempty"` Raw string `yaml:"raw,omitempty" json:"raw,omitempty"` }
type Request ¶
type Request struct { API string `yaml:"api" json:"api"` Method string `yaml:"method,omitempty" json:"method,omitempty" jsonschema:"enum=GET,enum=POST,enum=PUT,enum=DELETE"` Query SortedKeysStringMap `yaml:"query,omitempty" json:"query,omitempty"` Header map[string]string `yaml:"header,omitempty" json:"header,omitempty"` Cookie map[string]string `yaml:"cookie,omitempty" json:"cookie,omitempty"` Form map[string]string `yaml:"form,omitempty" json:"form,omitempty"` Body RequestBody `yaml:"body,omitempty" json:"body,omitempty"` BodyFromFile string `yaml:"bodyFromFile,omitempty" json:"bodyFromFile,omitempty"` }
Request represents a HTTP request
type RequestBody ¶ added in v0.0.16
type RequestBody struct { Value string `json:"value" yaml:"value"` // contains filtered or unexported fields }
func NewRequestBody ¶ added in v0.0.16
func NewRequestBody(val string) RequestBody
func (RequestBody) Bytes ¶ added in v0.0.18
func (e RequestBody) Bytes() (data []byte)
func (RequestBody) IsEmpty ¶ added in v0.0.18
func (e RequestBody) IsEmpty() bool
func (RequestBody) MarshalYAML ¶ added in v0.0.16
func (e RequestBody) MarshalYAML() (val interface{}, err error)
func (RequestBody) String ¶ added in v0.0.16
func (e RequestBody) String() string
func (*RequestBody) UnmarshalYAML ¶ added in v0.0.16
func (e *RequestBody) UnmarshalYAML(unmarshal func(interface{}) error) (err error)
type Response ¶
type Response struct { StatusCode int `yaml:"statusCode,omitempty" json:"statusCode,omitempty"` Body string `yaml:"body,omitempty" json:"body,omitempty"` Header map[string]string `yaml:"header,omitempty" json:"header,omitempty"` BodyFieldsExpect map[string]interface{} `yaml:"bodyFieldsExpect,omitempty" json:"bodyFieldsExpect,omitempty"` Verify []string `yaml:"verify,omitempty" json:"verify,omitempty"` ConditionalVerify []ConditionalVerify `yaml:"conditionalVerify,omitempty" json:"conditionalVerify,omitempty"` Schema string `yaml:"schema,omitempty" json:"schema,omitempty"` }
Response is the expected response
func (Response) GetBodyFieldsExpect ¶ added in v0.0.15
type Secure ¶ added in v0.0.14
type Secure struct { Insecure bool `yaml:"insecure,omitempty" json:"insecure,omitempty"` CertFile string `yaml:"cert,omitempty" json:"cert,omitempty"` CAFile string `yaml:"ca,omitempty" json:"ca,omitempty"` KeyFile string `yaml:"key,omitempty" json:"key,omitempty"` ServerName string `yaml:"serverName,omitempty" json:"serverName,omitempty"` }
type SortedKeysStringMap ¶ added in v0.0.14
type SortedKeysStringMap map[string]interface{}
func (SortedKeysStringMap) GetValue ¶ added in v0.0.16
func (m SortedKeysStringMap) GetValue(key string) string
func (SortedKeysStringMap) GetVerifier ¶ added in v0.0.16
func (m SortedKeysStringMap) GetVerifier(key string) (verifier *Verifier)
func (SortedKeysStringMap) Keys ¶ added in v0.0.14
func (m SortedKeysStringMap) Keys() (keys []string)
type Store ¶ added in v0.0.13
type Store struct { Name string Owner string Kind StoreKind Description string URL string Username string Password string ReadOnly bool Disabled bool Properties map[string]string }
func MapToStore ¶ added in v0.0.13
type StoreConfig ¶ added in v0.0.14
type StoreGetterAndSetter ¶ added in v0.0.13
type StoreGetterAndSetter interface { GetStores() (stores []Store, err error) GetStoresByOwner(owner string) (stores []Store, err error) GetStore(name string) (store *Store, err error) DeleteStore(name string) (err error) UpdateStore(store Store) (err error) CreateStore(store Store) (err error) GetStoreKinds() (kinds []StoreKind, err error) }
func NewStoreFactory ¶ added in v0.0.13
func NewStoreFactory(configDir string) StoreGetterAndSetter
NewStoreFactory creates a new store factory
type StoreWriterFactory ¶ added in v0.0.13
type TestCase ¶
type TestCase struct { ID string `yaml:"id,omitempty" json:"id,omitempty"` Name string `yaml:"name,omitempty" json:"name,omitempty"` Group string `yaml:"group,omitempty" json:"group,omitempty"` Before *Job `yaml:"before,omitempty" json:"before,omitempty"` After *Job `yaml:"after,omitempty" json:"after,omitempty"` Request Request `yaml:"request" json:"request"` Expect Response `yaml:"expect,omitempty" json:"expect,omitempty"` }
TestCase represents a test case
func ParseTestCaseFromData ¶ added in v0.0.5
ParseTestCaseFromData parses the data to a test case
type TestCaseResult ¶ added in v0.0.18
type TestCaseResult struct { StatusCode int `yaml:"statusCode,omitempty" json:"statusCode,omitempty"` Body string `yaml:"body,omitempty" json:"body,omitempty"` Header map[string]string `yaml:"header,omitempty" json:"header,omitempty"` Error string `yaml:"error,omitempty" json:"error,omitempty"` Id string `yaml:"id,omitempty" json:"id,omitempty"` Output string `yaml:"output,omitempty" json:"output,omitempty"` }
type TestResult ¶ added in v0.0.18
type TestResult struct { Message string `yaml:"message,omitempty" json:"message,omitempty"` Error string `yaml:"error,omitempty" json:"error,omitempty"` TestCaseResult []*TestCaseResult `yaml:"testCaseResult,omitempty" json:"testCaseResult,omitempty"` }
type TestSuite ¶ added in v0.0.2
type TestSuite struct { Name string `yaml:"name,omitempty" json:"name,omitempty"` API string `yaml:"api,omitempty" json:"api,omitempty"` Spec APISpec `yaml:"spec,omitempty" json:"spec,omitempty"` Param map[string]string `yaml:"param,omitempty" json:"param,omitempty"` Items []TestCase `yaml:"items,omitempty" json:"items,omitempty"` }
TestSuite represents a set of test cases
func ParseFromData ¶ added in v0.0.5
ParseFromData parses data and returns the test suite
func ParseFromStream ¶ added in v0.0.13
ParseFromStream parses the stream and returns the test suite
func ParseTestSuiteFromFile ¶ added in v0.0.13
ParseTestSuiteFromFile parses from suite path
type Writer ¶ added in v0.0.13
type Writer interface { Loader ListTestCase(suite string) (testcases []TestCase, err error) GetTestCase(suite, name string) (testcase TestCase, err error) CreateTestCase(suite string, testcase TestCase) (err error) UpdateTestCase(suite string, testcase TestCase) (err error) DeleteTestCase(suite, testcase string) (err error) ListHistoryTestSuite() (suites []HistoryTestSuite, err error) CreateHistoryTestCase(testcaseResult TestCaseResult, suite *TestSuite, historyHeader map[string]string) (err error) GetHistoryTestCaseWithResult(id string) (historyTestCase HistoryTestResult, err error) GetHistoryTestCase(id string) (historyTestCase HistoryTestCase, err error) DeleteHistoryTestCase(id string) (err error) DeleteAllHistoryTestCase(suite, name string) (err error) RenameTestCase(suite, oldName, newName string) (err error) GetTestCaseAllHistory(suite, name string) (historyTestCase []HistoryTestCase, err error) ListTestSuite() (suites []TestSuite, err error) GetTestSuite(name string, full bool) (suite TestSuite, err error) GetTestSuiteYaml(name string) (testSuiteYaml []byte, err error) CreateSuite(name, api string) (err error) GetSuite(name string) (*TestSuite, string, error) UpdateSuite(TestSuite) (err error) DeleteSuite(name string) (err error) RenameTestSuite(oldName, newName string) error Close() }
func NewFileWriter ¶ added in v0.0.13
func NewNonWriter ¶ added in v0.0.15
func NewNonWriter() Writer