@@ -23,7 +23,8 @@ import (
23
23
)
24
24
25
25
func lookupCaller (t * testing.T ) string {
26
- pc , _ , _ , ok := runtime .Caller (3 )
26
+ const module = `github.com/quay/claircore/`
27
+ pc , _ , _ , ok := runtime .Caller (2 )
27
28
if ! ok {
28
29
t .Fatal ("unable to get caller" )
29
30
}
@@ -33,14 +34,13 @@ func lookupCaller(t *testing.T) string {
33
34
if idx == - 1 {
34
35
t .Fatalf ("weird name: %q" , name )
35
36
}
36
- name = name [:idx ]
37
- return name
37
+ return strings .TrimPrefix (name [:idx ], module )
38
38
}
39
39
40
40
var (
41
41
// Alternatively, use ghcr.io ?
42
42
Registry = `quay.io`
43
- Namespace = `projectclair `
43
+ Namespace = `projectquay `
44
44
Tag = `latest`
45
45
)
46
46
@@ -69,6 +69,7 @@ const (
69
69
// Fetch ...
70
70
func Fetch [V Value , K Kind [V ]](ctx context.Context , t * testing.T ) []V {
71
71
t .Helper ()
72
+ repo := lookupCaller (t )
72
73
dir := filepath .Join (integration .PackageCacheDir (t ), "fixtures" )
73
74
if err := os .Mkdir (dir , 0755 ); err != nil && ! errors .Is (err , fs .ErrExist ) {
74
75
t .Fatal (err )
@@ -78,14 +79,15 @@ func Fetch[V Value, K Kind[V]](ctx context.Context, t *testing.T) []V {
78
79
79
80
c := regclient .New (
80
81
regclient .WithFS (sys ),
82
+ regclient .WithDockerCreds (),
81
83
)
82
84
tgt , err := ref .New ("ocidir://" + Tag )
83
85
if err != nil {
84
86
t .Fatal (err )
85
87
}
86
88
t .Run ("FetchFixtures" , func (t * testing.T ) {
87
89
integration .Skip (t )
88
- name := fmt .Sprintf ("%s/%s/%s:%s" , Registry , Namespace , lookupCaller ( t ) , Tag )
90
+ name := fmt .Sprintf ("%s/%s/%s:%s" , Registry , Namespace , repo , Tag )
89
91
t .Logf ("pulling fixtues referencing %q" , name )
90
92
remote , err := ref .New (name )
91
93
if err != nil {
@@ -105,11 +107,13 @@ func Fetch[V Value, K Kind[V]](ctx context.Context, t *testing.T) []V {
105
107
t .Fatalf ("unexpected error with local files: %v" , err )
106
108
}
107
109
108
- list , err := c .ReferrerList (ctx , tgt , scheme .WithReferrerAT (elem .ArtifactType ()))
110
+ at := elem .ArtifactType ()
111
+ list , err := c .ReferrerList (ctx , tgt , scheme .WithReferrerAT (at ))
109
112
if err != nil {
110
113
t .Fatal (err )
111
114
}
112
115
if list .IsEmpty () {
116
+ t .Logf ("no manifests of type %q for %s" , at , tgt .CommonName ())
113
117
return nil
114
118
}
115
119
@@ -120,14 +124,15 @@ func Fetch[V Value, K Kind[V]](ctx context.Context, t *testing.T) []V {
120
124
if err != nil {
121
125
t .Fatalf ("error fetching blob: %v" , err )
122
126
}
127
+ t .Logf ("found descriptor: %v" , d )
123
128
// Don't worry too much about the Reader; all tests are transitory, man.
124
129
var m oci.Manifest
125
130
if err := json .NewDecoder (rd ).Decode (& m ); err != nil {
126
131
t .Fatalf ("unexpected error decoding descriptor data: %v" , err )
127
132
}
128
133
rd .Close ()
129
134
var k K = & out [i ]
130
- if err := k .Load (ctx , dir , local , tgt , & m ); err != nil {
135
+ if err := k .Load (ctx , t , dir , local , tgt , & m ); err != nil {
131
136
t .Fatalf ("tk: %v" , err )
132
137
}
133
138
}
0 commit comments