diff options
| author | Miguel Pires <miguel.pires@canonical.com> | 2022-07-01 11:55:32 +0100 |
|---|---|---|
| committer | Miguel Pires <miguel.pires@canonical.com> | 2022-07-01 11:55:32 +0100 |
| commit | 5ed2c0b34484b74064b76419626b0a87959c469b (patch) | |
| tree | 609de1afa8ee94ae28a1a0d58bff005e56a41b34 | |
| parent | 85e3005fe0bd9fe864b5671bef1fc2df22e60fca (diff) | |
cmd/snap: simplify tests
Signed-off-by: Miguel Pires <miguel.pires@canonical.com>
| -rw-r--r-- | cmd/snap/cmd_debug_state_test.go | 36 |
1 files changed, 16 insertions, 20 deletions
diff --git a/cmd/snap/cmd_debug_state_test.go b/cmd/snap/cmd_debug_state_test.go index 905441be35..c9a4bb177b 100644 --- a/cmd/snap/cmd_debug_state_test.go +++ b/cmd/snap/cmd_debug_state_test.go @@ -454,20 +454,18 @@ func (s *SnapSuite) TestDebugConnectionPlugAndSlot(c *C) { stateFile := filepath.Join(dir, "test-state.json") c.Assert(ioutil.WriteFile(stateFile, stateConnsJSON, 0644), IsNil) - for i, connArg := range []string{"gnome-calculator:network,core:network"} { - s.ResetStdStreams() - rest, err := main.Parser(main.Client()).ParseArgs([]string{"debug", "state", fmt.Sprintf("--connection=%s", connArg), stateFile}) - c.Assert(err, IsNil) - c.Assert(rest, DeepEquals, []string{}) - c.Check(s.Stdout(), Matches, - "id: gnome-calculator:network core:network\n"+ - "auto: true\n"+ - "by-gadget: false\n"+ - "interface: network\n"+ - "undesired: false\n"+ - "\n", Commentf("#%d: %s", i, connArg)) - c.Check(s.Stderr(), Equals, "") - } + connArg := "gnome-calculator:network,core:network" + rest, err := main.Parser(main.Client()).ParseArgs([]string{"debug", "state", fmt.Sprintf("--connection=%s", connArg), stateFile}) + c.Assert(err, IsNil) + c.Assert(rest, DeepEquals, []string{}) + c.Check(s.Stdout(), Matches, + "id: gnome-calculator:network core:network\n"+ + "auto: true\n"+ + "by-gadget: false\n"+ + "interface: network\n"+ + "undesired: false\n"+ + "\n", Commentf("#0: %s", connArg)) + c.Check(s.Stderr(), Equals, "") } func (s *SnapSuite) TestDebugConnectionInvalidCombination(c *C) { @@ -475,12 +473,10 @@ func (s *SnapSuite) TestDebugConnectionInvalidCombination(c *C) { stateFile := filepath.Join(dir, "test-state.json") c.Assert(ioutil.WriteFile(stateFile, stateConnsJSON, 0644), IsNil) - for _, connArg := range []string{"gnome-calculator,core:network"} { - s.ResetStdStreams() - _, err := main.Parser(main.Client()).ParseArgs([]string{"debug", "state", fmt.Sprintf("--connection=%s", connArg), stateFile}) - c.Assert(err, ErrorMatches, fmt.Sprintf("invalid command with connection args: %s", connArg)) - c.Check(s.Stdout(), Equals, "") - } + connArg := "gnome-calculator,core:network" + _, err := main.Parser(main.Client()).ParseArgs([]string{"debug", "state", fmt.Sprintf("--connection=%s", connArg), stateFile}) + c.Assert(err, ErrorMatches, fmt.Sprintf("invalid command with connection args: %s", connArg)) + c.Check(s.Stdout(), Equals, "") } func (s *SnapSuite) TestDebugConnectionDetailsMany(c *C) { |
