github.com/kubeshop/testkube@v1.17.23/pkg/api/v1/testkube/model_test_content_extended.go (about) 1 // content could be fetched as file or dir (many files, e.g. Cypress project) in executor 2 package testkube 3 4 import "fmt" 5 6 type TestContentType string 7 8 const ( 9 TestContentTypeString TestContentType = "string" 10 TestContentTypeFileURI TestContentType = "file-uri" 11 TestContentTypeGitFile TestContentType = "git-file" 12 TestContentTypeGitDir TestContentType = "git-dir" 13 TestContentTypeGit TestContentType = "git" 14 TestContentTypeEmpty TestContentType = "" 15 ) 16 17 type ArgsModeType string 18 19 const ( 20 ArgsModeTypeAppend ArgsModeType = "append" 21 ArgsModeTypeOverride ArgsModeType = "override" 22 ArgsModeTypeReplace ArgsModeType = "replace" 23 ) 24 25 var ErrTestContentTypeNotFile = fmt.Errorf("unsupported content type use one of: file-uri, git-file, string") 26 var ErrTestContentTypeNotDir = fmt.Errorf("unsupported content type use one of: git-dir") 27 28 func NewStringTestContent(str string) *TestContent { 29 return &TestContent{ 30 Type_: string(TestContentTypeString), 31 Data: str, 32 } 33 } 34 35 // IsDir - for content fetched as dir 36 // 37 // Deprecated: check source data 38 func (c *TestContent) IsDir() bool { 39 return TestContentType(c.Type_) == TestContentTypeGitDir 40 41 } 42 43 // IsFile - for content fetched as file 44 // Deprected: check source data 45 func (c *TestContent) IsFile() bool { 46 return TestContentType(c.Type_) == TestContentTypeGitFile || 47 TestContentType(c.Type_) == TestContentTypeFileURI || 48 TestContentType(c.Type_) == TestContentTypeString 49 }