From b85eb2a7d2a5222ae833d9102369be4a9012c000 Mon Sep 17 00:00:00 2001 From: Rafid Bin Mostofa Date: Tue, 6 Aug 2024 13:47:21 +0600 Subject: [PATCH] fix: address review comments https://github.com/canonical/chisel/pull/101#pullrequestreview-2218924292 --- cmd/chisel/cmd_info.go | 2 +- cmd/chisel/cmd_info_test.go | 8 ++++---- internal/setup/setup.go | 21 ++++++++++++--------- tests/info/task.yaml | 2 +- 4 files changed, 18 insertions(+), 15 deletions(-) diff --git a/cmd/chisel/cmd_info.go b/cmd/chisel/cmd_info.go index 4b820ef8..3afbc360 100644 --- a/cmd/chisel/cmd_info.go +++ b/cmd/chisel/cmd_info.go @@ -134,5 +134,5 @@ func selectPackageSlices(release *setup.Release, queries []string) (packages []* } packages = append(packages, pkg) } - return + return packages, notFound } diff --git a/cmd/chisel/cmd_info_test.go b/cmd/chisel/cmd_info_test.go index 88a55aab..9fa8da7d 100644 --- a/cmd/chisel/cmd_info_test.go +++ b/cmd/chisel/cmd_info_test.go @@ -99,7 +99,7 @@ var infoTests = []infoTest{{ - mypkg2_myslice `, }, { - summary: "All kinds of path", + summary: "All kinds of paths", input: infoRelease, query: []string{"mypkg3"}, stdout: ` @@ -172,6 +172,7 @@ var infoTests = []infoTest{{ }} var testKey = testutil.PGPKeys["key1"] + var defaultChiselYaml = ` format: chisel-v1 archives: @@ -182,8 +183,7 @@ var defaultChiselYaml = ` v1-public-keys: test-key: id: ` + testKey.ID + ` - armor: |` + "\n" + testutil.PrefixEachLine(testKey.PubKeyArmor, "\t\t\t\t\t\t") + ` -` + armor: |` + "\n" + testutil.PrefixEachLine(testKey.PubKeyArmor, "\t\t\t\t\t\t") var infoRelease = map[string]string{ "chisel.yaml": string(defaultChiselYaml), @@ -255,6 +255,6 @@ func (s *ChiselSuite) TestInfoCommand(c *C) { } c.Assert(err, IsNil) test.stdout = string(testutil.Reindent(test.stdout)) - c.Assert(strings.TrimSpace(s.Stdout()), Equals, strings.TrimSpace(test.stdout)) + c.Assert(s.Stdout(), Equals, strings.TrimSpace(test.stdout)+"\n") } } diff --git a/internal/setup/setup.go b/internal/setup/setup.go index bcdfcc57..59a0f478 100644 --- a/internal/setup/setup.go +++ b/internal/setup/setup.go @@ -357,15 +357,14 @@ type yamlPackage struct { } type yamlPath struct { - Dir bool `yaml:"make,omitempty"` - Copy string `yaml:"copy,omitempty"` - Text *string `yaml:"text,omitempty"` - Symlink string `yaml:"symlink,omitempty"` - Mutable bool `yaml:"mutable,omitempty"` - - Until PathUntil `yaml:"until,omitempty"` - Arch yamlArch `yaml:"arch,omitempty"` - Mode yamlMode `yaml:"mode,omitempty"` + Dir bool `yaml:"make,omitempty"` + Copy string `yaml:"copy,omitempty"` + Text *string `yaml:"text,omitempty"` + Symlink string `yaml:"symlink,omitempty"` + Mutable bool `yaml:"mutable,omitempty"` + Until PathUntil `yaml:"until,omitempty"` + Arch yamlArch `yaml:"arch,omitempty"` + Mode yamlMode `yaml:"mode,omitempty"` } func (yp *yamlPath) MarshalYAML() (interface{}, error) { @@ -419,6 +418,8 @@ func (ya yamlArch) MarshalYAML() (interface{}, error) { return ya.List, nil } +var _ yaml.Marshaler = yamlArch{} + type yamlMode uint func (ym yamlMode) MarshalYAML() (interface{}, error) { @@ -433,6 +434,8 @@ func (ym yamlMode) MarshalYAML() (interface{}, error) { return node, nil } +var _ yaml.Marshaler = yamlMode(0) + type yamlSlice struct { Essential []string `yaml:"essential,omitempty"` Contents map[string]*yamlPath `yaml:"contents,omitempty"` diff --git a/tests/info/task.yaml b/tests/info/task.yaml index 079c4f82..395b53e1 100644 --- a/tests/info/task.yaml +++ b/tests/info/task.yaml @@ -1,4 +1,4 @@ -summary: Chisel can show detailed info about slices +summary: Chisel can show detailed information about slices execute: | # Install dependencies.