dive/dive/image/docker/testing.go
Alex Goodman d5e8a92968
Rework CI validation workflow and makefile (#460)
* rework CI validation workflow and makefile

* enable push

* fix job names

* fix license check

* fix snapshot builds

* fix acceptance tests

* fix linting

* disable pull request event

* rework windows runner caching

* disable release pipeline and add issue templates
2023-07-06 22:01:46 -04:00

37 lines
659 B
Go

package docker
import (
"os"
"testing"
"github.com/wagoodman/dive/dive/image"
)
func TestLoadArchive(tarPath string) (*ImageArchive, error) {
f, err := os.Open(tarPath)
if err != nil {
return nil, err
}
defer f.Close()
return NewImageArchive(f)
}
func TestAnalysisFromArchive(t *testing.T, path string) *image.AnalysisResult {
archive, err := TestLoadArchive(path)
if err != nil {
t.Fatalf("unable to fetch archive: %v", err)
}
img, err := archive.ToImage()
if err != nil {
t.Fatalf("unable to convert to image: %v", err)
}
result, err := img.Analyze()
if err != nil {
t.Fatalf("unable to analyze: %v", err)
}
return result
}