feat: support running load testing by loading profile

This commit is contained in:
xucong053
2022-05-19 22:58:16 +08:00
parent af78a8b83b
commit 584d7aeea0
5 changed files with 82 additions and 49 deletions

View File

@@ -6,6 +6,7 @@ import (
"os"
"os/exec"
"path/filepath"
"time"
"github.com/httprunner/funplugin/shared"
"github.com/pkg/errors"
@@ -13,6 +14,7 @@ import (
"github.com/httprunner/httprunner/v4/hrp/internal/builtin"
"github.com/httprunner/httprunner/v4/hrp/internal/sdk"
"github.com/httprunner/httprunner/v4/hrp/internal/version"
)
type PluginType string
@@ -23,6 +25,12 @@ const (
Go PluginType = "go"
)
type ProjectInfo struct {
ProjectName string `json:"project_name,omitempty" yaml:"project_name,omitempty"`
CreateTime time.Time `json:"create_time,omitempty" yaml:"create_time,omitempty"`
Version string `json:"hrp_version,omitempty" yaml:"hrp_version,omitempty"`
}
//go:embed templates/*
var templatesDir embed.FS
@@ -88,8 +96,17 @@ func CreateScaffold(projectName string, pluginType PluginType, force bool) error
return err
}
projectInfo := &ProjectInfo{
ProjectName: projectName,
CreateTime: time.Now(),
Version: version.VERSION,
}
// dump project information to file
err := builtin.Dump2JSON(projectInfo, filepath.Join(projectName, "proj.json"))
// create .gitignore
err := CopyFile("templates/gitignore", filepath.Join(projectName, ".gitignore"))
err = CopyFile("templates/gitignore", filepath.Join(projectName, ".gitignore"))
if err != nil {
return err
}