@@ -2812,25 +2812,49 @@ func TestListBuilds(t *testing.T) {
28122812 assert .Equal (t , "2.0.0" , names ["skill-b" ])
28132813 })
28142814
2815- t .Run ("artifact with no metadata still appears" , func (t * testing.T ) {
2815+ t .Run ("skill artifact with no extractable metadata still appears" , func (t * testing.T ) {
28162816 t .Parallel ()
28172817 ociStore , err := ociskills .NewStore (t .TempDir ())
28182818 require .NoError (t , err )
28192819
2820- // Store a minimal manifest with no config labels — extractOCIContent will fail
2821- // but the artifact should still appear with empty metadata fields.
2822- d , putErr := ociStore .PutManifest (t .Context (), []byte (`{"schemaVersion":2,"mediaType":"application/vnd.oci.image.index.v1+json","manifests":[]}` ))
2820+ // Store an index with ArtifactType set to the skill type but no child manifests —
2821+ // extractOCIContent will fail but the artifact should still appear with empty metadata fields.
2822+ skillIndex := `{"schemaVersion":2,"mediaType":"application/vnd.oci.image.index.v1+json","artifactType":"dev.toolhive.skills.v1","manifests":[]}`
2823+ d , putErr := ociStore .PutManifest (t .Context (), []byte (skillIndex ))
28232824 require .NoError (t , putErr )
2824- require .NoError (t , ociStore .Tag (t .Context (), d , "bare-tag" ))
2825+ require .NoError (t , ociStore .Tag (t .Context (), d , "bare-skill- tag" ))
28252826
28262827 svc := New (& storage.NoopSkillStore {}, WithOCIStore (ociStore ))
28272828 artifacts , err := svc .ListBuilds (t .Context ())
28282829 require .NoError (t , err )
28292830 require .Len (t , artifacts , 1 )
28302831
2831- assert .Equal (t , "bare-tag" , artifacts [0 ].Tag )
2832+ assert .Equal (t , "bare-skill- tag" , artifacts [0 ].Tag )
28322833 assert .Contains (t , artifacts [0 ].Digest , "sha256:" )
28332834 assert .Empty (t , artifacts [0 ].Name )
28342835 assert .Empty (t , artifacts [0 ].Version )
28352836 })
2837+
2838+ t .Run ("non-skill artifact is excluded" , func (t * testing.T ) {
2839+ t .Parallel ()
2840+ ociStore , err := ociskills .NewStore (t .TempDir ())
2841+ require .NoError (t , err )
2842+
2843+ // Store a valid skill artifact that should be returned.
2844+ skillDigest := buildTestArtifact (t , ociStore , "real-skill" , "1.0.0" )
2845+ require .NoError (t , ociStore .Tag (t .Context (), skillDigest , "real-skill" ))
2846+
2847+ // Store an index whose ArtifactType is not the skill type — simulates a
2848+ // remotely-pulled non-skill OCI artifact sharing the same store.
2849+ otherIndex := `{"schemaVersion":2,"mediaType":"application/vnd.oci.image.index.v1+json","artifactType":"application/vnd.docker.distribution.manifest.v2","manifests":[]}`
2850+ otherDigest , putErr := ociStore .PutManifest (t .Context (), []byte (otherIndex ))
2851+ require .NoError (t , putErr )
2852+ require .NoError (t , ociStore .Tag (t .Context (), otherDigest , "non-skill-tag" ))
2853+
2854+ svc := New (& storage.NoopSkillStore {}, WithOCIStore (ociStore ))
2855+ artifacts , err := svc .ListBuilds (t .Context ())
2856+ require .NoError (t , err )
2857+ require .Len (t , artifacts , 1 )
2858+ assert .Equal (t , "real-skill" , artifacts [0 ].Tag )
2859+ })
28362860}
0 commit comments