@@ -59,6 +59,9 @@ func TestConvertToRpcPkgs(t *testing.T) {
5959 Digest : "SHA1:901a7b55410321c4d35543506cff2a8613ef5aa2" ,
6060 Indirect : true ,
6161 Relationship : ftypes .RelationshipIndirect ,
62+ Repository : ftypes.PackageRepository {
63+ Class : ftypes .RepositoryClassThirdParty ,
64+ },
6265 Identifier : ftypes.PkgIdentifier {
6366 UID : "01" ,
6467 },
@@ -94,6 +97,9 @@ func TestConvertToRpcPkgs(t *testing.T) {
9497 Digest : "SHA1:901a7b55410321c4d35543506cff2a8613ef5aa2" ,
9598 Indirect : true ,
9699 Relationship : 4 ,
100+ Repository : & common.PackageRepository {
101+ Class : "third-party" ,
102+ },
97103 Identifier : & common.PkgIdentifier {
98104 Uid : "01" ,
99105 },
@@ -225,6 +231,9 @@ func TestConvertFromRpcPkgs(t *testing.T) {
225231 Uid : "63f8bef824b960e3" ,
226232 },
227233 Maintainer : "alice@example.com" ,
234+ Repository : & common.PackageRepository {
235+ Class : "third-party" ,
236+ },
228237 },
229238 },
230239 },
@@ -261,6 +270,9 @@ func TestConvertFromRpcPkgs(t *testing.T) {
261270 UID : "63f8bef824b960e3" ,
262271 },
263272 Maintainer : "alice@example.com" ,
273+ Repository : ftypes.PackageRepository {
274+ Class : ftypes .RepositoryClassThirdParty ,
275+ },
264276 },
265277 },
266278 },
@@ -273,6 +285,31 @@ func TestConvertFromRpcPkgs(t *testing.T) {
273285 }
274286}
275287
288+ func TestConvertPackageRepository (t * testing.T ) {
289+ tests := []struct {
290+ name string
291+ repo ftypes.PackageRepository
292+ rpcRepo * common.PackageRepository
293+ }{
294+ {
295+ name : "third-party" ,
296+ repo : ftypes.PackageRepository {Class : ftypes .RepositoryClassThirdParty },
297+ rpcRepo : & common.PackageRepository {Class : "third-party" },
298+ },
299+ {
300+ name : "empty class maps to nil" ,
301+ repo : ftypes.PackageRepository {},
302+ rpcRepo : nil ,
303+ },
304+ }
305+ for _ , tt := range tests {
306+ t .Run (tt .name , func (t * testing.T ) {
307+ assert .Equal (t , tt .rpcRepo , ConvertToRPCPackageRepository (tt .repo ))
308+ assert .Equal (t , tt .repo , ConvertFromRPCPackageRepository (tt .rpcRepo ))
309+ })
310+ }
311+ }
312+
276313func TestConvertToRpcVulns (t * testing.T ) {
277314 fixedPublishedDate := time .Unix (1257894000 , 0 )
278315 fixedLastModifiedDate := time .Unix (1257894010 , 0 )
0 commit comments