MCPcopy Create free account
hub / github.com/devfile/api / GetDevFileName

Function GetDevFileName

test/v200/utils/common/test_utils.go:143–160  ·  view source on GitHub ↗

GetDevFileName returns a qualified name of a devfile for use in a test. The devfile will be in a temporary directory and is named using the calling function's name.

()

Source from the content-addressed store, hash-verified

141// GetDevFileName returns a qualified name of a devfile for use in a test.
142// The devfile will be in a temporary directory and is named using the calling function's name.
143func GetDevFileName() string {
144 pc, fn, _, ok := runtime.Caller(1)
145 if !ok {
146 return tmpDir + "DefaultDevfile"
147 }
148
149 testFile := filepath.Base(fn)
150 testFileExtension := filepath.Ext(testFile)
151 subdir := testFile[0 : len(testFile)-len(testFileExtension)]
152 destDir := CreateTempDir(subdir)
153 callerName := runtime.FuncForPC(pc).Name()
154 pos1 := strings.LastIndex(callerName, "Test_")
155 devfileName := destDir + callerName[pos1:len(callerName)] + ".yaml"
156
157 LogInfoMessage(fmt.Sprintf("GetDevFileName : %s", devfileName))
158
159 return devfileName
160}
161
162// AddSuffixToFileName adds a specified suffix to the name of a specified file.
163// For example if the file is devfile.yaml and the suffix is 1, the result is devfile1.yaml

Callers

nothing calls this directly

Calls 3

CreateTempDirFunction · 0.85
LogInfoMessageFunction · 0.85
NameMethod · 0.80

Tested by

no test coverage detected