refactor(tests): remove hardcoded digests (#871)

Signed-off-by: Catalin Hofnar <catalin.hofnar@gmail.com>
This commit is contained in:
Catalin Hofnar
2022-10-19 06:43:56 +03:00
committed by GitHub
parent 7d08985f75
commit caf88ddb1e
4 changed files with 56 additions and 32 deletions
+23
View File
@@ -29,6 +29,29 @@ const (
SleepTime = 100 * time.Millisecond
)
// which: manifest, config, layer
func GetTestBlobDigest(image, which string) godigest.Digest {
prePath := "../test/data"
for _, err := os.Stat(prePath); err != nil; _, err = os.Stat(prePath) {
prePath = "../" + prePath
}
imgPath := path.Join(prePath, image)
manifest, config, layer := GetOciLayoutDigests(imgPath)
switch which {
case "manifest":
return manifest
case "config":
return config
case "layer":
return layer
}
return ""
}
var (
ErrPostBlob = errors.New("can't post blob")
ErrPutBlob = errors.New("can't put blob")