Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
Already on GitHub? Sign in to your account
integration-tests: add the first classic dimention tests #429
Merged
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
Jump to file or symbol
Failed to load files and symbols.
| @@ -0,0 +1,89 @@ | ||
| +// -*- Mode: Go; indent-tabs-mode: t -*- | ||
| +// +build !excludeintegration | ||
| + | ||
| +/* | ||
| + * Copyright (C) 2016 Canonical Ltd | ||
| + * | ||
| + * This program is free software: you can redistribute it and/or modify | ||
| + * it under the terms of the GNU General Public License version 3 as | ||
| + * published by the Free Software Foundation. | ||
| + * | ||
| + * This program is distributed in the hope that it will be useful, | ||
| + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| + * GNU General Public License for more details. | ||
| + * | ||
| + * You should have received a copy of the GNU General Public License | ||
| + * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| + * | ||
| + */ | ||
| + | ||
| +package tests | ||
| + | ||
| +import ( | ||
| + "os" | ||
| + | ||
| + "github.com/ubuntu-core/snappy/integration-tests/testutils/cli" | ||
| + "github.com/ubuntu-core/snappy/integration-tests/testutils/common" | ||
| + | ||
| + "gopkg.in/check.v1" | ||
| +) | ||
| + | ||
| +var _ = check.Suite(&classicDimensionSuite{}) | ||
| + | ||
| +type classicDimensionSuite struct { | ||
| + common.SnappySuite | ||
| +} | ||
| + | ||
| +func (s *classicDimensionSuite) enableClassic(c *check.C) { | ||
| + output := cli.ExecCommand(c, "sudo", "env", "https_proxy="+os.Getenv("https_proxy"), "snappy", "enable-classic") | ||
| + | ||
| + expected := "(?ms)" + | ||
| + ".*" + | ||
| + "Classic dimension enabled on this snappy system.\n" + | ||
| + "Use “snappy shell classic” to enter the classic dimension.\n" | ||
| + c.Assert(output, check.Matches, expected) | ||
| +} | ||
| + | ||
| +func (s *classicDimensionSuite) destroyClassic(c *check.C) { | ||
| + output := cli.ExecCommand(c, "sudo", "snappy", "destroy-classic") | ||
| + | ||
| + expected := "Classic dimension destroyed on this snappy system.\n" | ||
| + c.Assert(output, check.Equals, expected) | ||
| +} | ||
| + | ||
| +func (s *classicDimensionSuite) TestClassicShell(c *check.C) { | ||
| + s.enableClassic(c) | ||
| + defer s.destroyClassic(c) | ||
| + | ||
| + enteringOutput := cli.ExecCommand(c, "snappy", "shell", "classic") | ||
| + expectedEnteringOutput := "Entering classic dimension\n" + | ||
| + "\n" + | ||
| + "\n" + | ||
| + "The home directory is shared between snappy and the classic dimension.\n" + | ||
| + "Run \"exit\" to leave the classic shell.\n" + | ||
| + "\n" | ||
| + c.Assert(enteringOutput, check.Equals, expectedEnteringOutput) | ||
| +} | ||
| + | ||
| +func (s *classicDimensionSuite) TestDestroyUnexistingClassicMustPrintError(c *check.C) { | ||
| + output, err := cli.ExecCommandErr("sudo", "snappy", "destroy-classic") | ||
| + | ||
| + c.Check(err, check.NotNil, | ||
| + check.Commentf("Trying to destroy unexisting classic dimension did not exit with an error")) | ||
| + c.Assert(string(output), check.Equals, | ||
| + "Classic dimension is not enabled.\n", | ||
| + check.Commentf("Wrong error message")) | ||
| +} | ||
| + | ||
| +func (s *classicDimensionSuite) TestReEnableClassicMustPrintError(c *check.C) { | ||
| + s.enableClassic(c) | ||
| + defer s.destroyClassic(c) | ||
| + output, err := cli.ExecCommandErr("sudo", "snappy", "enable-classic") | ||
| + | ||
| + c.Check(err, check.NotNil, | ||
| + check.Commentf("Trying to re-enable classic dimension did not exit with an error")) | ||
| + c.Assert(string(output), check.Equals, | ||
| + "Classic dimension is already enabled.\n", | ||
| + check.Commentf("Wrong error message")) | ||
| +} |