From 46c875868b9b75deb57e6430101088277b79628e Mon Sep 17 00:00:00 2001 From: Hank Donnay Date: Mon, 11 Sep 2023 20:21:26 -0500 Subject: [PATCH] claircore: update tests for `test` package changes These tests should probably be audited and removed where they don't make sense anymore. Signed-off-by: Hank Donnay --- layer_integration_test.go | 54 +++++++++++++-------------------------- 1 file changed, 18 insertions(+), 36 deletions(-) diff --git a/layer_integration_test.go b/layer_integration_test.go index 8cda5ec7b..609aad577 100644 --- a/layer_integration_test.go +++ b/layer_integration_test.go @@ -1,7 +1,3 @@ -// we will use the claircore_test package here to avoid import cycles when -// importing the fetcher.fetcher. using the fetcher is an attempt to not repeat -// a lot of layer fetching code. if this pattern continues reconsider importing anything -// into claircore package package claircore_test import ( @@ -9,39 +5,33 @@ import ( "context" "testing" - "github.com/quay/claircore" "github.com/quay/claircore/test" "github.com/quay/claircore/test/integration" ) -var goldenLayers []test.LayerSpec +// TODO(hank) These tests should be OK to remove, as the tarfs code now +// encapsulates a better way to do this and exercises that in its tests. -func init() { - id, err := claircore.ParseDigest("sha256:35c102085707f703de2d9eaad8752d6fe1b8f02b5d2149f1d8357c9cc7fb7d0a") - if err != nil { - panic(err) - } - goldenLayers = []test.LayerSpec{ - { - Domain: "docker.io", - Repo: "library/ubuntu", - ID: id, - }, - } +var goldenLayers = []test.LayerRef{ + { + Registry: "docker.io", + Name: "library/ubuntu", + Digest: "sha256:35c102085707f703de2d9eaad8752d6fe1b8f02b5d2149f1d8357c9cc7fb7d0a", + }, +} + +type filesTestcase struct { + name string + layers []test.LayerRef + // A list of paths we know exist in the retrieved layer(s). + // We will test to make sure their associated buffer is full. + paths []string } func TestLayerFilesMiss(t *testing.T) { integration.Skip(t) ctx := context.Background() - var tt = []struct { - // name of the test - name string - // the number of layers to generate for the test - layers []test.LayerSpec - // a list of paths we know exist in the retrieved layer(s). we wil test to make sure their associated - // buffer is full - paths []string - }{ + var tt = []filesTestcase{ { name: "ubuntu:18.04 fake path, leading slash", layers: goldenLayers, @@ -71,15 +61,7 @@ func TestLayerFilesMiss(t *testing.T) { func TestLayerFilesHit(t *testing.T) { integration.Skip(t) ctx := context.Background() - var tt = []struct { - // name of the test - name string - // the number of layers to generate for the test - layers []test.LayerSpec - // a list of paths we know exist in the retrieved layer(s). we wil test to make sure their associated - // buffer is full - paths []string - }{ + var tt = []filesTestcase{ { name: "ubuntu:18.04 os-release (linked file), leading slash, inmem fetch", layers: goldenLayers,