Skip to content

Commit

Permalink
rename internal package to avoid clashing
Browse files Browse the repository at this point in the history
  • Loading branch information
letFunny committed Jan 7, 2025
1 parent dcecefa commit 99ae181
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 64 deletions.
2 changes: 1 addition & 1 deletion internal/manifest/log.go → internal/manifestutil/log.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package manifest
package manifestutil

import (
"fmt"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package manifest
package manifestutil

import (
"fmt"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package manifest_test
package manifestutil_test

import (
"bytes"
Expand All @@ -8,7 +8,7 @@ import (
. "gopkg.in/check.v1"

"github.com/canonical/chisel/internal/archive"
imanifest "github.com/canonical/chisel/internal/manifest"
"github.com/canonical/chisel/internal/manifestutil"
"github.com/canonical/chisel/internal/setup"
"github.com/canonical/chisel/internal/testutil"
"github.com/canonical/chisel/pkg/manifest"
Expand Down Expand Up @@ -87,7 +87,7 @@ func (s *S) TestFindPaths(c *C) {
for _, test := range findPathsTests {
c.Logf("Summary: %s", test.summary)

manifestSlices := imanifest.FindPaths(test.slices)
manifestSlices := manifestutil.FindPaths(test.slices)

slicesByName := map[string]*setup.Slice{}
for _, slice := range test.slices {
Expand Down Expand Up @@ -117,17 +117,17 @@ var slice2 = &setup.Slice{

var generateManifestTests = []struct {
summary string
report *imanifest.Report
report *manifestutil.Report
packageInfo []*archive.PackageInfo
selection []*setup.Slice
expected *testutil.ManifestContents
error string
}{{
summary: "Basic",
selection: []*setup.Slice{slice1, slice2},
report: &imanifest.Report{
report: &manifestutil.Report{
Root: "/",
Entries: map[string]imanifest.ReportEntry{
Entries: map[string]manifestutil.ReportEntry{
"/file": {
Path: "/file",
Mode: 0456,
Expand Down Expand Up @@ -207,9 +207,9 @@ var generateManifestTests = []struct {
},
}, {
summary: "Missing slice",
report: &imanifest.Report{
report: &manifestutil.Report{
Root: "/",
Entries: map[string]imanifest.ReportEntry{
Entries: map[string]manifestutil.ReportEntry{
"/file": {
Path: "/file",
Mode: 0456,
Expand All @@ -224,9 +224,9 @@ var generateManifestTests = []struct {
error: `internal error: invalid manifest: path "/file" refers to missing slice package1_slice1`,
}, {
summary: "Missing package",
report: &imanifest.Report{
report: &manifestutil.Report{
Root: "/",
Entries: map[string]imanifest.ReportEntry{
Entries: map[string]manifestutil.ReportEntry{
"/file": {
Path: "/file",
Mode: 0456,
Expand All @@ -241,9 +241,9 @@ var generateManifestTests = []struct {
error: `internal error: invalid manifest: slice package1_slice1 refers to missing package "package1"`,
}, {
summary: "Invalid path: link set for regular file",
report: &imanifest.Report{
report: &manifestutil.Report{
Root: "/",
Entries: map[string]imanifest.ReportEntry{
Entries: map[string]manifestutil.ReportEntry{
"/file": {
Path: "/file",
Mode: 0456,
Expand All @@ -255,9 +255,9 @@ var generateManifestTests = []struct {
error: `internal error: invalid manifest: path "/file" has invalid options: link set for regular file`,
}, {
summary: "Invalid path: slices is empty",
report: &imanifest.Report{
report: &manifestutil.Report{
Root: "/",
Entries: map[string]imanifest.ReportEntry{
Entries: map[string]manifestutil.ReportEntry{
"/file": {
Path: "/file",
Mode: 0456,
Expand All @@ -267,9 +267,9 @@ var generateManifestTests = []struct {
error: `internal error: invalid manifest: path "/file" has invalid options: slices is empty`,
}, {
summary: "Invalid path: link set for symlink",
report: &imanifest.Report{
report: &manifestutil.Report{
Root: "/",
Entries: map[string]imanifest.ReportEntry{
Entries: map[string]manifestutil.ReportEntry{
"/link": {
Path: "/link",
Mode: 0456 | fs.ModeSymlink,
Expand All @@ -280,9 +280,9 @@ var generateManifestTests = []struct {
error: `internal error: invalid manifest: path "/link" has invalid options: link not set for symlink`,
}, {
summary: "Invalid path: sha256 set for symlink",
report: &imanifest.Report{
report: &manifestutil.Report{
Root: "/",
Entries: map[string]imanifest.ReportEntry{
Entries: map[string]manifestutil.ReportEntry{
"/link": {
Path: "/link",
Mode: 0456 | fs.ModeSymlink,
Expand All @@ -295,9 +295,9 @@ var generateManifestTests = []struct {
error: `internal error: invalid manifest: path "/link" has invalid options: sha256 set for symlink`,
}, {
summary: "Invalid path: final_sha256 set for symlink",
report: &imanifest.Report{
report: &manifestutil.Report{
Root: "/",
Entries: map[string]imanifest.ReportEntry{
Entries: map[string]manifestutil.ReportEntry{
"/link": {
Path: "/link",
Mode: 0456 | fs.ModeSymlink,
Expand All @@ -310,9 +310,9 @@ var generateManifestTests = []struct {
error: `internal error: invalid manifest: path "/link" has invalid options: final_sha256 set for symlink`,
}, {
summary: "Invalid path: size set for symlink",
report: &imanifest.Report{
report: &manifestutil.Report{
Root: "/",
Entries: map[string]imanifest.ReportEntry{
Entries: map[string]manifestutil.ReportEntry{
"/link": {
Path: "/link",
Mode: 0456 | fs.ModeSymlink,
Expand All @@ -325,9 +325,9 @@ var generateManifestTests = []struct {
error: `internal error: invalid manifest: path "/link" has invalid options: size set for symlink`,
}, {
summary: "Invalid path: link set for directory",
report: &imanifest.Report{
report: &manifestutil.Report{
Root: "/",
Entries: map[string]imanifest.ReportEntry{
Entries: map[string]manifestutil.ReportEntry{
"/dir": {
Path: "/dir",
Mode: 0456 | fs.ModeDir,
Expand All @@ -339,9 +339,9 @@ var generateManifestTests = []struct {
error: `internal error: invalid manifest: path "/dir" has invalid options: link set for directory`,
}, {
summary: "Invalid path: sha256 set for directory",
report: &imanifest.Report{
report: &manifestutil.Report{
Root: "/",
Entries: map[string]imanifest.ReportEntry{
Entries: map[string]manifestutil.ReportEntry{
"/dir": {
Path: "/dir",
Mode: 0456 | fs.ModeDir,
Expand All @@ -353,9 +353,9 @@ var generateManifestTests = []struct {
error: `internal error: invalid manifest: path "/dir" has invalid options: sha256 set for directory`,
}, {
summary: "Invalid path: final_sha256 set for directory",
report: &imanifest.Report{
report: &manifestutil.Report{
Root: "/",
Entries: map[string]imanifest.ReportEntry{
Entries: map[string]manifestutil.ReportEntry{
"/dir": {
Path: "/dir",
Mode: 0456 | fs.ModeDir,
Expand All @@ -367,9 +367,9 @@ var generateManifestTests = []struct {
error: `internal error: invalid manifest: path "/dir" has invalid options: final_sha256 set for directory`,
}, {
summary: "Invalid path: size set for directory",
report: &imanifest.Report{
report: &manifestutil.Report{
Root: "/",
Entries: map[string]imanifest.ReportEntry{
Entries: map[string]manifestutil.ReportEntry{
"/dir": {
Path: "/dir",
Mode: 0456 | fs.ModeDir,
Expand Down Expand Up @@ -428,13 +428,13 @@ func (s *S) TestGenerateManifests(c *C) {
}}
}

options := &imanifest.WriteOptions{
options := &manifestutil.WriteOptions{
PackageInfo: test.packageInfo,
Selection: test.selection,
Report: test.report,
}
var buffer bytes.Buffer
err := imanifest.Write(options, &buffer)
err := manifestutil.Write(options, &buffer)
if test.error != "" {
c.Assert(err, ErrorMatches, test.error)
continue
Expand All @@ -450,13 +450,13 @@ func (s *S) TestGenerateManifests(c *C) {
}

func (s *S) TestGenerateNoManifests(c *C) {
report, err := imanifest.NewReport("/")
report, err := manifestutil.NewReport("/")
c.Assert(err, IsNil)
options := &imanifest.WriteOptions{
options := &manifestutil.WriteOptions{
Report: report,
}
var buffer bytes.Buffer
err = imanifest.Write(options, &buffer)
err = manifestutil.Write(options, &buffer)
c.Assert(err, IsNil)

var reader io.Reader = &buffer
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package manifest
package manifestutil

import (
"fmt"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package manifest_test
package manifestutil_test

import (
"io/fs"

. "gopkg.in/check.v1"

"github.com/canonical/chisel/internal/fsutil"
"github.com/canonical/chisel/internal/manifest"
"github.com/canonical/chisel/internal/manifestutil"
"github.com/canonical/chisel/internal/setup"
)

Expand Down Expand Up @@ -64,13 +64,13 @@ var reportTests = []struct {
add []sliceAndEntry
mutate []*fsutil.Entry
// indexed by path.
expected map[string]manifest.ReportEntry
expected map[string]manifestutil.ReportEntry
// error after adding the last [sliceAndEntry].
err string
}{{
summary: "Regular directory",
add: []sliceAndEntry{{entry: sampleDir, slice: oneSlice}},
expected: map[string]manifest.ReportEntry{
expected: map[string]manifestutil.ReportEntry{
"/example-dir/": {
Path: "/example-dir/",
Mode: fs.ModeDir | 0654,
Expand All @@ -83,7 +83,7 @@ var reportTests = []struct {
{entry: sampleDir, slice: oneSlice},
{entry: sampleDir, slice: otherSlice},
},
expected: map[string]manifest.ReportEntry{
expected: map[string]manifestutil.ReportEntry{
"/example-dir/": {
Path: "/example-dir/",
Mode: fs.ModeDir | 0654,
Expand All @@ -93,7 +93,7 @@ var reportTests = []struct {
}, {
summary: "Regular file",
add: []sliceAndEntry{{entry: sampleFile, slice: oneSlice}},
expected: map[string]manifest.ReportEntry{
expected: map[string]manifestutil.ReportEntry{
"/example-file": {
Path: "/example-file",
Mode: 0777,
Expand All @@ -105,7 +105,7 @@ var reportTests = []struct {
}, {
summary: "Regular file link",
add: []sliceAndEntry{{entry: sampleLink, slice: oneSlice}},
expected: map[string]manifest.ReportEntry{
expected: map[string]manifestutil.ReportEntry{
"/example-link": {
Path: "/example-link",
Mode: 0777,
Expand All @@ -120,7 +120,7 @@ var reportTests = []struct {
{entry: sampleDir, slice: oneSlice},
{entry: sampleFile, slice: otherSlice},
},
expected: map[string]manifest.ReportEntry{
expected: map[string]manifestutil.ReportEntry{
"/example-dir/": {
Path: "/example-dir/",
Mode: fs.ModeDir | 0654,
Expand All @@ -141,7 +141,7 @@ var reportTests = []struct {
{entry: sampleFile, slice: oneSlice},
{entry: sampleFile, slice: oneSlice},
},
expected: map[string]manifest.ReportEntry{
expected: map[string]manifestutil.ReportEntry{
"/example-file": {
Path: "/example-file",
Mode: 0777,
Expand Down Expand Up @@ -225,7 +225,7 @@ var reportTests = []struct {
{entry: sampleDir, slice: oneSlice},
},
mutate: []*fsutil.Entry{&sampleFileMutated},
expected: map[string]manifest.ReportEntry{
expected: map[string]manifestutil.ReportEntry{
"/example-dir/": {
Path: "/example-dir/",
Mode: fs.ModeDir | 0654,
Expand All @@ -247,7 +247,7 @@ var reportTests = []struct {
{entry: sampleFile, slice: oneSlice},
},
mutate: []*fsutil.Entry{&sampleFile},
expected: map[string]manifest.ReportEntry{
expected: map[string]manifestutil.ReportEntry{
"/example-file": {
Path: "/example-file",
Mode: 0777,
Expand All @@ -272,7 +272,7 @@ var reportTests = []struct {
func (s *S) TestReport(c *C) {
for _, test := range reportTests {
var err error
report, err := manifest.NewReport("/base/")
report, err := manifestutil.NewReport("/base/")
c.Assert(err, IsNil)
for _, si := range test.add {
err = report.Add(si.slice, &si.entry)
Expand All @@ -290,12 +290,12 @@ func (s *S) TestReport(c *C) {
}

func (s *S) TestRootRelativePath(c *C) {
_, err := manifest.NewReport("../base/")
_, err := manifestutil.NewReport("../base/")
c.Assert(err, ErrorMatches, `cannot use relative path for report root: "../base/"`)
}

func (s *S) TestRootOnlySlash(c *C) {
report, err := manifest.NewReport("/")
report, err := manifestutil.NewReport("/")
c.Assert(err, IsNil)
c.Assert(report.Root, Equals, "/")
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package manifest_test
package manifestutil_test

import (
"testing"

. "gopkg.in/check.v1"

"github.com/canonical/chisel/internal/manifest"
"github.com/canonical/chisel/internal/manifestutil"
)

func Test(t *testing.T) { TestingT(t) }
Expand All @@ -15,11 +15,11 @@ type S struct{}
var _ = Suite(&S{})

func (s *S) SetUpTest(c *C) {
manifest.SetDebug(true)
manifest.SetLogger(c)
manifestutil.SetDebug(true)
manifestutil.SetLogger(c)
}

func (s *S) TearDownTest(c *C) {
manifest.SetDebug(false)
manifest.SetLogger(nil)
manifestutil.SetDebug(false)
manifestutil.SetLogger(nil)
}
Loading

0 comments on commit 99ae181

Please sign in to comment.