github.com/kubiko/snapd@v0.0.0-20201013125620-d4f3094d9ddf/cmd/snap/cmd_debug_bootvars_test.go (about) 1 // -*- Mode: Go; indent-tabs-mode: t -*- 2 3 /* 4 * Copyright (C) 2019 Canonical Ltd 5 * 6 * This program is free software: you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License version 3 as 8 * published by the Free Software Foundation. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this program. If not, see <http://www.gnu.org/licenses/>. 17 * 18 */ 19 20 package main_test 21 22 import ( 23 "gopkg.in/check.v1" 24 25 "github.com/snapcore/snapd/bootloader" 26 "github.com/snapcore/snapd/bootloader/bootloadertest" 27 snap "github.com/snapcore/snapd/cmd/snap" 28 "github.com/snapcore/snapd/release" 29 ) 30 31 func (s *SnapSuite) TestDebugBootvars(c *check.C) { 32 restore := release.MockOnClassic(false) 33 defer restore() 34 bloader := bootloadertest.Mock("mock", c.MkDir()) 35 bootloader.Force(bloader) 36 bloader.BootVars = map[string]string{ 37 "snap_mode": "try", 38 "unrelated": "thing", 39 "snap_core": "core18_1.snap", 40 "snap_try_core": "core18_2.snap", 41 "snap_kernel": "pc-kernel_3.snap", 42 "snap_try_kernel": "pc-kernel_4.snap", 43 } 44 45 rest, err := snap.Parser(snap.Client()).ParseArgs([]string{"debug", "boot-vars"}) 46 c.Assert(err, check.IsNil) 47 c.Assert(rest, check.DeepEquals, []string{}) 48 c.Check(s.Stdout(), check.Equals, `snap_mode=try 49 snap_core=core18_1.snap 50 snap_try_core=core18_2.snap 51 snap_kernel=pc-kernel_3.snap 52 snap_try_kernel=pc-kernel_4.snap 53 `) 54 c.Check(s.Stderr(), check.Equals, "") 55 } 56 57 func (s *SnapSuite) TestDebugBootvarsNotOnClassic(c *check.C) { 58 restore := release.MockOnClassic(true) 59 defer restore() 60 _, err := snap.Parser(snap.Client()).ParseArgs([]string{"debug", "boot-vars"}) 61 c.Assert(err, check.ErrorMatches, `the "boot-vars" command is not available on classic systems`) 62 }