mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-13 08:19:44 +08:00
fix: unittest
This commit is contained in:
@@ -36,4 +36,4 @@ Copyright 2017 debugtalk
|
||||
* [hrp run](hrp_run.md) - run API test with go engine
|
||||
* [hrp startproject](hrp_startproject.md) - create a scaffold project
|
||||
|
||||
###### Auto generated by spf13/cobra on 9-May-2022
|
||||
###### Auto generated by spf13/cobra on 20-May-2022
|
||||
|
||||
@@ -31,6 +31,7 @@ hrp boom [flags]
|
||||
--max-rps int Max RPS that boomer can generate, disabled by default.
|
||||
--mem-profile string Enable memory profiling.
|
||||
--mem-profile-duration duration Memory profile duration. (default 30s)
|
||||
--profile string profile for load testing
|
||||
--prometheus-gateway string Prometheus Pushgateway url.
|
||||
--request-increase-rate string Request increase rate, disabled by default. (default "-1")
|
||||
--spawn-count int The number of users to spawn for load testing (default 1)
|
||||
@@ -41,4 +42,4 @@ hrp boom [flags]
|
||||
|
||||
* [hrp](hrp.md) - Next-Generation API Testing Solution.
|
||||
|
||||
###### Auto generated by spf13/cobra on 9-May-2022
|
||||
###### Auto generated by spf13/cobra on 20-May-2022
|
||||
|
||||
@@ -18,4 +18,4 @@ hrp convert $path... [flags]
|
||||
|
||||
* [hrp](hrp.md) - Next-Generation API Testing Solution.
|
||||
|
||||
###### Auto generated by spf13/cobra on 9-May-2022
|
||||
###### Auto generated by spf13/cobra on 20-May-2022
|
||||
|
||||
@@ -24,4 +24,4 @@ hrp har2case $har_path... [flags]
|
||||
|
||||
* [hrp](hrp.md) - Next-Generation API Testing Solution.
|
||||
|
||||
###### Auto generated by spf13/cobra on 9-May-2022
|
||||
###### Auto generated by spf13/cobra on 20-May-2022
|
||||
|
||||
@@ -16,4 +16,4 @@ hrp pytest $path ... [flags]
|
||||
|
||||
* [hrp](hrp.md) - Next-Generation API Testing Solution.
|
||||
|
||||
###### Auto generated by spf13/cobra on 9-May-2022
|
||||
###### Auto generated by spf13/cobra on 20-May-2022
|
||||
|
||||
@@ -35,4 +35,4 @@ hrp run $path... [flags]
|
||||
|
||||
* [hrp](hrp.md) - Next-Generation API Testing Solution.
|
||||
|
||||
###### Auto generated by spf13/cobra on 9-May-2022
|
||||
###### Auto generated by spf13/cobra on 20-May-2022
|
||||
|
||||
@@ -20,4 +20,4 @@ hrp startproject $project_name [flags]
|
||||
|
||||
* [hrp](hrp.md) - Next-Generation API Testing Solution.
|
||||
|
||||
###### Auto generated by spf13/cobra on 9-May-2022
|
||||
###### Auto generated by spf13/cobra on 20-May-2022
|
||||
|
||||
@@ -27,6 +27,7 @@ const (
|
||||
|
||||
type ProjectInfo struct {
|
||||
ProjectName string `json:"project_name,omitempty" yaml:"project_name,omitempty"`
|
||||
ProjectPath string `json:"project_path,omitempty" yaml:"project_path,omitempty"`
|
||||
CreateTime time.Time `json:"create_time,omitempty" yaml:"create_time,omitempty"`
|
||||
Version string `json:"hrp_version,omitempty" yaml:"hrp_version,omitempty"`
|
||||
}
|
||||
@@ -76,6 +77,12 @@ func CreateScaffold(projectName string, pluginType PluginType, force bool) error
|
||||
os.RemoveAll(projectName)
|
||||
}
|
||||
|
||||
// get project abs path
|
||||
projectPath, err := filepath.Abs(projectName)
|
||||
if err != nil {
|
||||
projectPath = projectName
|
||||
}
|
||||
|
||||
// create project folders
|
||||
if err := builtin.CreateFolder(projectName); err != nil {
|
||||
return err
|
||||
@@ -98,12 +105,16 @@ func CreateScaffold(projectName string, pluginType PluginType, force bool) error
|
||||
|
||||
projectInfo := &ProjectInfo{
|
||||
ProjectName: projectName,
|
||||
ProjectPath: projectPath,
|
||||
CreateTime: time.Now(),
|
||||
Version: version.VERSION,
|
||||
}
|
||||
|
||||
// dump project information to file
|
||||
err := builtin.Dump2JSON(projectInfo, filepath.Join(projectName, "proj.json"))
|
||||
err = builtin.Dump2JSON(projectInfo, filepath.Join(projectName, "proj.json"))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// create .gitignore
|
||||
err = CopyFile("templates/gitignore", filepath.Join(projectName, ".gitignore"))
|
||||
|
||||
@@ -207,7 +207,7 @@ func TestLoadTestCases(t *testing.T) {
|
||||
if !assert.Nil(t, err) {
|
||||
t.Fatal()
|
||||
}
|
||||
if !assert.Equal(t, len(testCases), 4) {
|
||||
if !assert.Equal(t, 4, len(testCases)) {
|
||||
t.Fatal()
|
||||
}
|
||||
|
||||
|
||||
@@ -287,8 +287,8 @@ func LoadTestCases(iTestCases ...ITestCase) ([]*TestCase, error) {
|
||||
testCasePath := TestCasePath(path)
|
||||
tc, err := testCasePath.ToTestCase()
|
||||
if err != nil {
|
||||
log.Error().Err(err).Str("path", path).Msg("load testcase failed")
|
||||
return errors.Wrap(err, "load testcase failed")
|
||||
log.Warn().Err(err).Str("path", path).Msg("load testcase failed")
|
||||
return nil
|
||||
}
|
||||
testCases = append(testCases, tc)
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user