Skip to content

Commit

Permalink
fix:added layer info in packages (#1248)
Browse files Browse the repository at this point in the history
* added layer info in packages

* fixed unit cases
  • Loading branch information
tonaim authored Sep 22, 2021
1 parent 982f35b commit 8d13234
Show file tree
Hide file tree
Showing 5 changed files with 188 additions and 141 deletions.
2 changes: 2 additions & 0 deletions pkg/rpc/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ func ConvertToRPCPkgs(pkgs []ftypes.Package) []*common.Package {
SrcRelease: pkg.SrcRelease,
SrcEpoch: int32(pkg.SrcEpoch),
License: pkg.License,
Layer: ConvertToRPCLayer(pkg.Layer),
})
}
return rpcPkgs
Expand All @@ -52,6 +53,7 @@ func ConvertFromRPCPkgs(rpcPkgs []*common.Package) []ftypes.Package {
SrcRelease: pkg.SrcRelease,
SrcEpoch: int(pkg.SrcEpoch),
License: pkg.License,
Layer: ConvertFromRPCLayer(pkg.Layer),
})
}
return pkgs
Expand Down
16 changes: 16 additions & 0 deletions pkg/rpc/convert_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ func TestConvertToRpcPkgs(t *testing.T) {
SrcRelease: "1",
SrcEpoch: 2,
License: "MIT",
Layer: ftypes.Layer{
Digest: "sha256:6a428f9f83b0a29f1fdd2ccccca19a9bab805a925b8eddf432a5a3d3da04afbc",
DiffID: "sha256:39982b2a789afc156fff00c707d0ff1c6ab4af8f1666a8df4787714059ce24e7",
},
},
},
},
Expand All @@ -56,6 +60,10 @@ func TestConvertToRpcPkgs(t *testing.T) {
SrcRelease: "1",
SrcEpoch: 2,
License: "MIT",
Layer: &common.Layer{
Digest: "sha256:6a428f9f83b0a29f1fdd2ccccca19a9bab805a925b8eddf432a5a3d3da04afbc",
DiffId: "sha256:39982b2a789afc156fff00c707d0ff1c6ab4af8f1666a8df4787714059ce24e7",
},
},
},
},
Expand Down Expand Up @@ -91,6 +99,10 @@ func TestConvertFromRpcPkgs(t *testing.T) {
SrcRelease: "1",
SrcEpoch: 2,
License: "MIT",
Layer: &common.Layer{
Digest: "sha256:6a428f9f83b0a29f1fdd2ccccca19a9bab805a925b8eddf432a5a3d3da04afbc",
DiffId: "sha256:39982b2a789afc156fff00c707d0ff1c6ab4af8f1666a8df4787714059ce24e7",
},
},
},
},
Expand All @@ -106,6 +118,10 @@ func TestConvertFromRpcPkgs(t *testing.T) {
SrcRelease: "1",
SrcEpoch: 2,
License: "MIT",
Layer: ftypes.Layer{
Digest: "sha256:6a428f9f83b0a29f1fdd2ccccca19a9bab805a925b8eddf432a5a3d3da04afbc",
DiffID: "sha256:39982b2a789afc156fff00c707d0ff1c6ab4af8f1666a8df4787714059ce24e7",
},
},
},
},
Expand Down
16 changes: 16 additions & 0 deletions pkg/rpc/server/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,10 @@ func TestCacheServer_PutBlob(t *testing.T) {
SrcVersion: "1.2.3",
SrcRelease: "1",
SrcEpoch: 2,
Layer: &common.Layer{
Digest: "sha256:154ad0735c360b212b167f424d33a62305770a1fcfb6363882f5c436cfbd9812",
DiffId: "sha256:b2a1a2d80bf0c747a4f6b0ca6af5eef23f043fcdb1ed4f3a3e750aef2dc68079",
},
},
{
Name: "vim-minimal",
Expand All @@ -321,6 +325,10 @@ func TestCacheServer_PutBlob(t *testing.T) {
SrcVersion: "7.4.160",
SrcRelease: "5.el7",
SrcEpoch: 2,
Layer: &common.Layer{
Digest: "sha256:154ad0735c360b212b167f424d33a62305770a1fcfb6363882f5c436cfbd9812",
DiffId: "sha256:b2a1a2d80bf0c747a4f6b0ca6af5eef23f043fcdb1ed4f3a3e750aef2dc68079",
},
},
},
},
Expand Down Expand Up @@ -371,6 +379,10 @@ func TestCacheServer_PutBlob(t *testing.T) {
SrcVersion: "1.2.3",
SrcRelease: "1",
SrcEpoch: 2,
Layer: ftypes.Layer{
Digest: "sha256:154ad0735c360b212b167f424d33a62305770a1fcfb6363882f5c436cfbd9812",
DiffID: "sha256:b2a1a2d80bf0c747a4f6b0ca6af5eef23f043fcdb1ed4f3a3e750aef2dc68079",
},
},
{
Name: "vim-minimal",
Expand All @@ -382,6 +394,10 @@ func TestCacheServer_PutBlob(t *testing.T) {
SrcVersion: "7.4.160",
SrcRelease: "5.el7",
SrcEpoch: 2,
Layer: ftypes.Layer{
Digest: "sha256:154ad0735c360b212b167f424d33a62305770a1fcfb6363882f5c436cfbd9812",
DiffID: "sha256:b2a1a2d80bf0c747a4f6b0ca6af5eef23f043fcdb1ed4f3a3e750aef2dc68079",
},
},
},
},
Expand Down
Loading

0 comments on commit 8d13234

Please sign in to comment.