mirror of
https://github.com/mudler/LocalAI.git
synced 2025-12-30 22:20:20 -06:00
We can't use the mutate.Extract written bytes as current status as that will be bigger than the compressed image size. Image manifest don't have any guarantee of the type of artifact (can be compressed or not) when showing the layer size. Split the extraction process in two parts: Downloading and extracting as a flattened system, in this way we can display the status of downloading and extracting accordingly. This change also fixes a small nuance in detecting installed backends, now it's more consistent and looks if a metadata.json and/or a path with a `run.sh` file is present. Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
38 lines
876 B
Go
38 lines
876 B
Go
package oci_test
|
|
|
|
import (
|
|
"os"
|
|
"runtime"
|
|
|
|
. "github.com/mudler/LocalAI/pkg/oci" // Update with your module path
|
|
. "github.com/onsi/ginkgo/v2"
|
|
. "github.com/onsi/gomega"
|
|
)
|
|
|
|
var _ = Describe("OCI", func() {
|
|
|
|
Context("when template is loaded successfully", func() {
|
|
It("should evaluate the template correctly", func() {
|
|
if runtime.GOOS == "darwin" {
|
|
Skip("Skipping test on darwin")
|
|
}
|
|
imageName := "alpine"
|
|
img, err := GetImage(imageName, "", nil, nil)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
|
|
size, err := GetOCIImageSize(imageName, "", nil, nil)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
|
|
Expect(size).ToNot(Equal(int64(0)))
|
|
|
|
// Create tempdir
|
|
dir, err := os.MkdirTemp("", "example")
|
|
Expect(err).NotTo(HaveOccurred())
|
|
defer os.RemoveAll(dir)
|
|
|
|
err = ExtractOCIImage(img, imageName, dir, nil)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
})
|
|
})
|
|
})
|