github.com/saucelabs/saucectl@v0.175.1/internal/report/captor/captor.go (about) 1 package captor 2 3 import ( 4 "sync" 5 6 "github.com/saucelabs/saucectl/internal/report" 7 ) 8 9 // Default is the default, global instance of Reporter. Use judiciously. 10 var Default = Reporter{} 11 12 // Reporter is a simple implementation for report.Reporter, a no-output reporter for capturing test results. 13 type Reporter struct { 14 TestResults []report.TestResult 15 lock sync.Mutex 16 } 17 18 // Add adds the test result. 19 func (r *Reporter) Add(t report.TestResult) { 20 r.lock.Lock() 21 defer r.lock.Unlock() 22 r.TestResults = append(r.TestResults, t) 23 } 24 25 // GetAll returns all added test results, unless they've been purged via Reset(). 26 func (r *Reporter) GetAll() []report.TestResult { 27 return r.TestResults 28 } 29 30 // Render does nothing. 31 func (r *Reporter) Render() { 32 // no op 33 } 34 35 // Reset resets the reporter to its initial state. This action will delete all test results. 36 func (r *Reporter) Reset() { 37 r.lock.Lock() 38 defer r.lock.Unlock() 39 r.TestResults = make([]report.TestResult, 0) 40 } 41 42 // ArtifactRequirements returns a list of artifact types are this reporter requires to create a proper report. 43 func (r *Reporter) ArtifactRequirements() []report.ArtifactType { 44 return nil 45 }