mirror of
https://github.com/openshift/openshift-mcp-server.git
synced 2025-10-17 14:27:48 +03:00
Refactor tests to new approach before adding more functionality. Signed-off-by: Marc Nuri <marc@marcnuri.com>
22 lines
365 B
Go
22 lines
365 B
Go
package test
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"runtime"
|
|
)
|
|
|
|
func Must[T any](v T, err error) T {
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return v
|
|
}
|
|
|
|
func ReadFile(path ...string) string {
|
|
_, file, _, _ := runtime.Caller(1)
|
|
filePath := filepath.Join(append([]string{filepath.Dir(file)}, path...)...)
|
|
fileBytes := Must(os.ReadFile(filePath))
|
|
return string(fileBytes)
|
|
}
|