github.com/saucelabs/saucectl@v0.175.1/internal/cypress/suite/suite.go (about) 1 package suite 2 3 import ( 4 "time" 5 6 "github.com/saucelabs/saucectl/internal/insights" 7 ) 8 9 // Suite represents the general test suite configuration. 10 type Suite struct { 11 Name string `yaml:"name,omitempty" json:"name"` 12 Browser string `yaml:"browser,omitempty" json:"browser"` 13 BrowserVersion string `yaml:"browserVersion,omitempty" json:"browserVersion"` 14 PlatformName string `yaml:"platformName,omitempty" json:"platformName"` 15 ScreenResolution string `yaml:"screenResolution,omitempty" json:"screenResolution"` 16 Timeout time.Duration `yaml:"timeout,omitempty" json:"timeout"` 17 Shard string `yaml:"shard,omitempty" json:"-"` 18 Headless bool `yaml:"headless,omitempty" json:"headless"` 19 PreExec []string `yaml:"preExec,omitempty" json:"preExec"` 20 TimeZone string `yaml:"timeZone,omitempty" json:"timeZone"` 21 Env map[string]string `yaml:"env,omitempty" json:"env"` 22 PassThreshold int `yaml:"passThreshold,omitempty" json:"-"` 23 } 24 25 // SortByHistory sorts the suites in the order of job history 26 func SortByHistory(suites []Suite, history insights.JobHistory) []Suite { 27 hash := map[string]Suite{} 28 for _, s := range suites { 29 hash[s.Name] = s 30 } 31 var res []Suite 32 for _, s := range history.TestCases { 33 if v, ok := hash[s.Name]; ok { 34 res = append(res, v) 35 delete(hash, s.Name) 36 } 37 } 38 for _, v := range suites { 39 if _, ok := hash[v.Name]; ok { 40 res = append(res, v) 41 } 42 } 43 return res 44 }