mirror of
https://github.com/httprunner/httprunner.git
synced 2026-06-03 06:49:38 +08:00
tests: add examples with scaffold
This commit is contained in:
29
hrp/internal/scaffold/examples_test.go
Normal file
29
hrp/internal/scaffold/examples_test.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package scaffold
|
||||
|
||||
import (
|
||||
"os"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestGenDemoExamples(t *testing.T) {
|
||||
dir := "../../../examples/demo-with-go-plugin"
|
||||
os.RemoveAll(dir)
|
||||
err := CreateScaffold(dir, Go)
|
||||
if err != nil {
|
||||
t.Fail()
|
||||
}
|
||||
|
||||
dir = "../../../examples/demo-with-py-plugin"
|
||||
os.RemoveAll(dir)
|
||||
err = CreateScaffold(dir, Py)
|
||||
if err != nil {
|
||||
t.Fail()
|
||||
}
|
||||
|
||||
dir = "../../../examples/demo-without-plugin"
|
||||
os.RemoveAll(dir)
|
||||
err = CreateScaffold(dir, Ignore)
|
||||
if err != nil {
|
||||
t.Fail()
|
||||
}
|
||||
}
|
||||
@@ -68,12 +68,18 @@ func CreateScaffold(projectName string, pluginType PluginType) error {
|
||||
if err := builtin.CreateFolder(filepath.Join(projectName, "har")); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := builtin.CreateFile(filepath.Join(projectName, "har", ".keep"), ""); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := builtin.CreateFolder(filepath.Join(projectName, "testcases")); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := builtin.CreateFolder(filepath.Join(projectName, "reports")); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := builtin.CreateFile(filepath.Join(projectName, "reports", ".keep"), ""); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// create .gitignore
|
||||
err := CopyFile("templates/gitignore", filepath.Join(projectName, ".gitignore"))
|
||||
@@ -88,8 +94,8 @@ func CreateScaffold(projectName string, pluginType PluginType) error {
|
||||
|
||||
// create demo testcases
|
||||
if pluginType == Ignore {
|
||||
err := CopyFile("templates/testcases/demo_without_plugin.json",
|
||||
filepath.Join(projectName, "testcases", "demo_without_plugin.json"))
|
||||
err := CopyFile("templates/testcases/demo_without_funplugin.json",
|
||||
filepath.Join(projectName, "testcases", "demo_without_funplugin.json"))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user