mirror of
https://github.com/containers/skopeo.git
synced 2025-08-28 11:03:19 +00:00
gopkg.in/check.v1 hasn't had any commit since Nov 2020. That's not a immediate issue for a test-only dependency, but because it hides access to the standard library *testing.T, eventually it will become limiting. Also, using the same framework for unit and integration tests seems practical. This is mostly a batch copy&paste job, with a fairly high risk of unexpected breakage. Also, I didn't take much time at all to carefully choose between assert.* and require.*; we can tune that as failures show up. Signed-off-by: Miloslav Trmač <mitr@redhat.com>
47 lines
941 B
Go
47 lines
941 B
Go
package suite
|
|
|
|
import "time"
|
|
|
|
// SuiteInformation stats stores stats for the whole suite execution.
|
|
type SuiteInformation struct {
|
|
Start, End time.Time
|
|
TestStats map[string]*TestInformation
|
|
}
|
|
|
|
// TestInformation stores information about the execution of each test.
|
|
type TestInformation struct {
|
|
TestName string
|
|
Start, End time.Time
|
|
Passed bool
|
|
}
|
|
|
|
func newSuiteInformation() *SuiteInformation {
|
|
testStats := make(map[string]*TestInformation)
|
|
|
|
return &SuiteInformation{
|
|
TestStats: testStats,
|
|
}
|
|
}
|
|
|
|
func (s SuiteInformation) start(testName string) {
|
|
s.TestStats[testName] = &TestInformation{
|
|
TestName: testName,
|
|
Start: time.Now(),
|
|
}
|
|
}
|
|
|
|
func (s SuiteInformation) end(testName string, passed bool) {
|
|
s.TestStats[testName].End = time.Now()
|
|
s.TestStats[testName].Passed = passed
|
|
}
|
|
|
|
func (s SuiteInformation) Passed() bool {
|
|
for _, stats := range s.TestStats {
|
|
if !stats.Passed {
|
|
return false
|
|
}
|
|
}
|
|
|
|
return true
|
|
}
|