From 2da93086a4823d62927a6547625f14628b5ea4a1 Mon Sep 17 00:00:00 2001 From: debugtalk Date: Mon, 28 Mar 2022 20:42:43 +0800 Subject: [PATCH] change: trigger actions on push to main branch --- .github/workflows/hrp-scaffold.yml | 2 ++ .github/workflows/smoketest.yml | 2 ++ .github/workflows/unittest.yml | 2 ++ hrp/convert_test.go | 4 ++-- hrp/models.go | 6 +++--- hrp/runner.go | 4 ++-- hrp/runner_test.go | 4 ++-- 7 files changed, 15 insertions(+), 9 deletions(-) diff --git a/.github/workflows/hrp-scaffold.yml b/.github/workflows/hrp-scaffold.yml index b3a5931e..b5caed98 100644 --- a/.github/workflows/hrp-scaffold.yml +++ b/.github/workflows/hrp-scaffold.yml @@ -2,6 +2,8 @@ name: Run scaffold for hrp on: push: + branches: + - main pull_request: types: [synchronize] diff --git a/.github/workflows/smoketest.yml b/.github/workflows/smoketest.yml index a638edfd..90bf1e8e 100644 --- a/.github/workflows/smoketest.yml +++ b/.github/workflows/smoketest.yml @@ -2,6 +2,8 @@ name: run smoke tests for httprunner on: push: + branches: + - main pull_request: types: [synchronize] diff --git a/.github/workflows/unittest.yml b/.github/workflows/unittest.yml index fb6e3b5d..7ee267d3 100644 --- a/.github/workflows/unittest.yml +++ b/.github/workflows/unittest.yml @@ -2,6 +2,8 @@ name: Run unittests on: push: + branches: + - main pull_request: types: [synchronize] diff --git a/hrp/convert_test.go b/hrp/convert_test.go index 948f9a4c..2b0556fb 100644 --- a/hrp/convert_test.go +++ b/hrp/convert_test.go @@ -153,7 +153,7 @@ var demoTestCaseWithoutPlugin = &TestCase{ } func TestGenDemoTestCase(t *testing.T) { - tCase := convertTestCase(demoTestCaseWithPlugin) + tCase := demoTestCaseWithPlugin.ToTCase() err := builtin.Dump2JSON(tCase, demoTestCaseWithPluginJSONPath.GetPath()) if err != nil { t.Fail() @@ -163,7 +163,7 @@ func TestGenDemoTestCase(t *testing.T) { t.Fail() } - tCase = convertTestCase(demoTestCaseWithoutPlugin) + tCase = demoTestCaseWithoutPlugin.ToTCase() err = builtin.Dump2JSON(tCase, demoTestCaseWithoutPluginJSONPath.GetPath()) if err != nil { t.Fail() diff --git a/hrp/models.go b/hrp/models.go index 87f31702..4247cf4a 100644 --- a/hrp/models.go +++ b/hrp/models.go @@ -323,11 +323,11 @@ func (tc *TestCase) ToTestCase() (*TestCase, error) { return tc, nil } -func convertTestCase(testcase *TestCase) *TCase { +func (tc *TestCase) ToTCase() *TCase { tCase := &TCase{ - Config: testcase.Config, + Config: tc.Config, } - for _, step := range testcase.TestSteps { + for _, step := range tc.TestSteps { tCase.TestSteps = append(tCase.TestSteps, step.ToStruct()) } return tCase diff --git a/hrp/runner.go b/hrp/runner.go index aac98b40..b0e50c7c 100644 --- a/hrp/runner.go +++ b/hrp/runner.go @@ -567,7 +567,7 @@ func (r *caseRunner) runStepRendezvous(rendezvous *Rendezvous) (stepResult *step } func (r *caseRunner) isPreRendezvousAllReleased(rendezvous *Rendezvous) bool { - tCase := convertTestCase(r.TestCase) + tCase := r.TestCase.ToTCase() for _, step := range tCase.TestSteps { preRendezvous := step.Rendezvous if preRendezvous == nil { @@ -614,7 +614,7 @@ func (r *Rendezvous) setReleased() { } func initRendezvous(testcase *TestCase, total int64) []*Rendezvous { - tCase := convertTestCase(testcase) + tCase := testcase.ToTCase() var rendezvousList []*Rendezvous for _, step := range tCase.TestSteps { if step.Rendezvous == nil { diff --git a/hrp/runner_test.go b/hrp/runner_test.go index 2b7c41b4..85216814 100644 --- a/hrp/runner_test.go +++ b/hrp/runner_test.go @@ -287,12 +287,12 @@ func TestRunCaseWithRefAPI(t *testing.T) { func TestLoadTestCases(t *testing.T) { // load test cases from folder path - tc := TestCasePath(templatesDir + "testcases") + tc := TestCasePath("../examples/demo-with-py-plugin/testcases/") testCases, err := loadTestCases(&tc) if !assert.Nil(t, err) { t.Fail() } - if !assert.GreaterOrEqual(t, len(testCases), 5) { + if !assert.Equal(t, len(testCases), 3) { t.Fail() }