github.com/saucelabs/saucectl@v0.175.1/internal/framework/framework.go (about) 1 package framework 2 3 import ( 4 "context" 5 "strings" 6 "time" 7 ) 8 9 // Framework represents a test framework (e.g. cypress). 10 type Framework struct { 11 Name string 12 Version string 13 } 14 15 // MetadataService represents an interface for retrieving framework metadata. 16 type MetadataService interface { 17 Frameworks(ctx context.Context) ([]string, error) 18 Versions(ctx context.Context, frameworkName string) ([]Metadata, error) 19 } 20 21 // Metadata represents test runner metadata. 22 type Metadata struct { 23 FrameworkName string 24 FrameworkVersion string 25 EOLDate time.Time 26 RemovalDate time.Time 27 DockerImage string 28 GitRelease string 29 Platforms []Platform 30 CloudRunnerVersion string 31 BrowserDefaults map[string]string 32 } 33 34 func (m *Metadata) IsDeprecated() bool { 35 return time.Now().After(m.EOLDate) 36 } 37 38 func (m *Metadata) IsFlaggedForRemoval() bool { 39 return time.Now().After(m.RemovalDate) 40 } 41 42 // Platform represent a supported platform. 43 type Platform struct { 44 PlatformName string 45 BrowserNames []string 46 } 47 48 // HasPlatform returns true if the provided Metadata has a matching platform. 49 func HasPlatform(m Metadata, platform string) bool { 50 for _, p := range m.Platforms { 51 if strings.EqualFold(platform, p.PlatformName) { 52 return true 53 } 54 } 55 56 return false 57 } 58 59 // PlatformNames extracts platform names from the given platforms and returns them. 60 func PlatformNames(platforms []Platform) []string { 61 var pp []string 62 for _, platform := range platforms { 63 pp = append(pp, platform.PlatformName) 64 } 65 66 return pp 67 }