Skip to content

Commit

Permalink
test(manifest): restore basic and add basic hard link
Browse files Browse the repository at this point in the history
  • Loading branch information
zhijie-yang committed Dec 3, 2024
1 parent 138448b commit 098d980
Showing 1 changed file with 107 additions and 24 deletions.
131 changes: 107 additions & 24 deletions internal/manifest/manifest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,16 +303,6 @@ var generateManifestTests = []struct {
Size: 1234,
Slices: map[*setup.Slice]bool{slice1: true},
FinalSHA256: "final-hash",
HardLinkID: 1,
},
"/hardlink": {
Path: "/hardlink",
Mode: 0456,
SHA256: "hash",
Size: 1234,
Slices: map[*setup.Slice]bool{slice1: true},
FinalSHA256: "final-hash",
HardLinkID: 1,
},
"/link": {
Path: "/link",
Expand Down Expand Up @@ -342,16 +332,6 @@ var generateManifestTests = []struct {
Size: 1234,
SHA256: "hash",
FinalSHA256: "final-hash",
HardLinkID: 1,
}, {
Kind: "path",
Path: "/hardlink",
Mode: "0456",
Slices: []string{"package1_slice1"},
Size: 1234,
SHA256: "hash",
FinalSHA256: "final-hash",
HardLinkID: 1,
}, {
Kind: "path",
Path: "/link",
Expand Down Expand Up @@ -383,10 +363,6 @@ var generateManifestTests = []struct {
Kind: "content",
Slice: "package1_slice1",
Path: "/file",
}, {
Kind: "content",
Slice: "package1_slice1",
Path: "/hardlink",
}, {
Kind: "content",
Slice: "package1_slice1",
Expand Down Expand Up @@ -571,6 +547,113 @@ var generateManifestTests = []struct {
},
},
error: `internal error: invalid manifest: path "/dir" has invalid options: size set for directory`,
}, {
summary: "Basic hard link",
selection: []*setup.Slice{slice1, slice2},
report: &manifest.Report{
Root: "/",
Entries: map[string]manifest.ReportEntry{
"/file": {
Path: "/file",
Mode: 0456,
SHA256: "hash",
Size: 1234,
Slices: map[*setup.Slice]bool{slice1: true},
FinalSHA256: "final-hash",
HardLinkID: 1,
},
"/hardlink": {
Path: "/hardlink",
Mode: 0456,
SHA256: "hash",
Size: 1234,
Slices: map[*setup.Slice]bool{slice1: true},
FinalSHA256: "final-hash",
HardLinkID: 1,
},
"/link": {
Path: "/link",
Mode: 0567 | fs.ModeSymlink,
Link: "/target",
Slices: map[*setup.Slice]bool{slice1: true, slice2: true},
},
},
},
packageInfo: []*archive.PackageInfo{{
Name: "package1",
Version: "v1",
Arch: "a1",
SHA256: "s1",
}, {
Name: "package2",
Version: "v2",
Arch: "a2",
SHA256: "s2",
}},
expected: &manifestContents{
Paths: []*manifest.Path{{
Kind: "path",
Path: "/file",
Mode: "0456",
Slices: []string{"package1_slice1"},
Size: 1234,
SHA256: "hash",
FinalSHA256: "final-hash",
HardLinkID: 1,
}, {
Kind: "path",
Path: "/hardlink",
Mode: "0456",
Slices: []string{"package1_slice1"},
Size: 1234,
SHA256: "hash",
FinalSHA256: "final-hash",
HardLinkID: 1,
}, {
Kind: "path",
Path: "/link",
Link: "/target",
Mode: "0567",
Slices: []string{"package1_slice1", "package2_slice2"},
}},
Packages: []*manifest.Package{{
Kind: "package",
Name: "package1",
Version: "v1",
Digest: "s1",
Arch: "a1",
}, {
Kind: "package",
Name: "package2",
Version: "v2",
Digest: "s2",
Arch: "a2",
}},
Slices: []*manifest.Slice{{
Kind: "slice",
Name: "package1_slice1",
}, {
Kind: "slice",
Name: "package2_slice2",
}},
Contents: []*manifest.Content{{
Kind: "content",
Slice: "package1_slice1",
Path: "/file",
}, {
Kind: "content",
Slice: "package1_slice1",
Path: "/hardlink",
}, {
Kind: "content",
Slice: "package1_slice1",
Path: "/link",
}, {
Kind: "content",
Slice: "package2_slice2",
Path: "/link",
}},
},
}, {
summary: "Skipped hard link id",
report: &manifest.Report{
Expand Down

0 comments on commit 098d980

Please sign in to comment.