github.com/hugh712/snapd@v0.0.0-20200910133618-1a99902bd583/overlord/configstate/configcore/backlight_test.go (about) 1 // -*- Mode: Go; indent-tabs-mode: t -*- 2 3 /* 4 * Copyright (C) 2020 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 configcore_test 21 22 import ( 23 "os" 24 "path/filepath" 25 26 . "gopkg.in/check.v1" 27 28 "github.com/snapcore/snapd/dirs" 29 "github.com/snapcore/snapd/overlord/configstate/configcore" 30 "github.com/snapcore/snapd/release" 31 ) 32 33 type backlightSuite struct { 34 configcoreSuite 35 } 36 37 var _ = Suite(&backlightSuite{}) 38 39 func (s *backlightSuite) SetUpTest(c *C) { 40 s.configcoreSuite.SetUpTest(c) 41 42 err := os.MkdirAll(filepath.Join(dirs.GlobalRootDir, "/etc/"), 0755) 43 c.Assert(err, IsNil) 44 } 45 46 func (s *backlightSuite) TestConfigureBacklightServiceMaskIntegration(c *C) { 47 restore := release.MockOnClassic(false) 48 defer restore() 49 50 s.systemctlArgs = nil 51 err := configcore.Run(&mockConf{ 52 state: s.state, 53 conf: map[string]interface{}{ 54 "system.disable-backlight-service": true, 55 }, 56 }) 57 c.Assert(err, IsNil) 58 c.Check(s.systemctlArgs, DeepEquals, [][]string{ 59 {"--root", dirs.GlobalRootDir, "mask", "systemd-backlight@.service"}, 60 }) 61 } 62 63 func (s *backlightSuite) TestConfigureBacklightServiceUnmaskIntegration(c *C) { 64 restore := release.MockOnClassic(false) 65 defer restore() 66 67 s.systemctlArgs = nil 68 err := configcore.Run(&mockConf{ 69 state: s.state, 70 conf: map[string]interface{}{ 71 "system.disable-backlight-service": false, 72 }, 73 }) 74 c.Assert(err, IsNil) 75 c.Check(s.systemctlArgs, DeepEquals, [][]string{ 76 {"--root", dirs.GlobalRootDir, "unmask", "systemd-backlight@.service"}, 77 }) 78 } 79 80 func (s *backlightSuite) TestFilesystemOnlyApply(c *C) { 81 conf := configcore.PlainCoreConfig(map[string]interface{}{ 82 "system.disable-backlight-service": "true", 83 }) 84 tmpDir := c.MkDir() 85 c.Assert(configcore.FilesystemOnlyApply(tmpDir, conf, nil), IsNil) 86 87 c.Check(s.systemctlArgs, DeepEquals, [][]string{ 88 {"--root", tmpDir, "mask", "systemd-backlight@.service"}, 89 }) 90 }