@@ -14,7 +14,6 @@ import (
1414 "github.com/andreyvit/diff"
1515 "github.com/antonmedv/expr"
1616 "github.com/antonmedv/expr/vm"
17- "github.com/linuxsuren/api-testing/pkg/apispec"
1817 "github.com/linuxsuren/api-testing/pkg/runner/kubernetes"
1918 "github.com/linuxsuren/api-testing/pkg/testing"
2019 fakeruntime "github.com/linuxsuren/go-fake-runtime"
@@ -71,54 +70,6 @@ func (w *defaultLevelWriter) Debug(format string, a ...any) {
7170 w .Fprintf (w .Writer , 7 , format , a ... )
7271}
7372
74- // TestCaseRunner represents a test case runner
75- type TestCaseRunner interface {
76- RunTestCase (testcase * testing.TestCase , dataContext interface {}, ctx context.Context ) (output interface {}, err error )
77- WithOutputWriter (io.Writer ) TestCaseRunner
78- WithWriteLevel (level string ) TestCaseRunner
79- WithTestReporter (TestReporter ) TestCaseRunner
80- WithExecer (fakeruntime.Execer ) TestCaseRunner
81- }
82-
83- // ReportRecord represents the raw data of a HTTP request
84- type ReportRecord struct {
85- Method string
86- API string
87- Body string
88- BeginTime time.Time
89- EndTime time.Time
90- Error error
91- }
92-
93- // Duration returns the duration between begin and end time
94- func (r * ReportRecord ) Duration () time.Duration {
95- return r .EndTime .Sub (r .BeginTime )
96- }
97-
98- // ErrorCount returns the count number of errors
99- func (r * ReportRecord ) ErrorCount () int {
100- if r .Error == nil {
101- return 0
102- }
103- return 1
104- }
105-
106- // GetErrorMessage returns the error message
107- func (r * ReportRecord ) GetErrorMessage () string {
108- if r .ErrorCount () > 0 {
109- return r .Body
110- } else {
111- return ""
112- }
113- }
114-
115- // NewReportRecord creates a record, and set the begin time to be now
116- func NewReportRecord () * ReportRecord {
117- return & ReportRecord {
118- BeginTime : time .Now (),
119- }
120- }
121-
12273// ReportResult represents the report result of a set of the same API requests
12374type ReportResult struct {
12475 API string
@@ -151,19 +102,6 @@ func (r ReportResultSlice) Swap(i, j int) {
151102 r [j ] = tmp
152103}
153104
154- // ReportResultWriter is the interface of the report writer
155- type ReportResultWriter interface {
156- Output ([]ReportResult ) error
157- WithAPIConverage (apiConverage apispec.APIConverage ) ReportResultWriter
158- }
159-
160- // TestReporter is the interface of the report
161- type TestReporter interface {
162- PutRecord (* ReportRecord )
163- GetAllRecords () []* ReportRecord
164- ExportAllReportResults () (ReportResultSlice , error )
165- }
166-
167105type simpleTestCaseRunner struct {
168106 testReporter TestReporter
169107 writer io.Writer
@@ -318,18 +256,6 @@ func (r *simpleTestCaseRunner) WithExecer(execer fakeruntime.Execer) TestCaseRun
318256 return r
319257}
320258
321- func (r * simpleTestCaseRunner ) doCleanPrepare (testcase * testing.TestCase ) (err error ) {
322- count := len (testcase .Before .Items )
323- for i := count - 1 ; i >= 0 ; i -- {
324- item := testcase .Before .Items [i ]
325-
326- if err = r .execer .RunCommand ("kubectl" , "delete" , "-f" , item ); err != nil {
327- return
328- }
329- }
330- return
331- }
332-
333259func expectInt (name string , expect , actual int ) (err error ) {
334260 if expect != actual {
335261 err = fmt .Errorf ("case: %s, expect %d, actual %d" , name , expect , actual )
0 commit comments