github.com/Lephar/snapd@v0.0.0-20210825215435-c7fba9cef4d2/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 ) 31 32 type backlightSuite struct { 33 configcoreSuite 34 } 35 36 var _ = Suite(&backlightSuite{}) 37 38 func (s *backlightSuite) SetUpTest(c *C) { 39 s.configcoreSuite.SetUpTest(c) 40 41 err := os.MkdirAll(filepath.Join(dirs.GlobalRootDir, "/etc/"), 0755) 42 c.Assert(err, IsNil) 43 } 44 45 func (s *backlightSuite) TestConfigureBacklightServiceMaskIntegration(c *C) { 46 s.systemctlArgs = nil 47 err := configcore.Run(coreDev, &mockConf{ 48 state: s.state, 49 conf: map[string]interface{}{ 50 "system.disable-backlight-service": true, 51 }, 52 }) 53 c.Assert(err, IsNil) 54 c.Check(s.systemctlArgs, DeepEquals, [][]string{ 55 {"--root", dirs.GlobalRootDir, "mask", "systemd-backlight@.service"}, 56 }) 57 } 58 59 func (s *backlightSuite) TestConfigureBacklightServiceUnmaskIntegration(c *C) { 60 s.systemctlArgs = nil 61 err := configcore.Run(coreDev, &mockConf{ 62 state: s.state, 63 conf: map[string]interface{}{ 64 "system.disable-backlight-service": false, 65 }, 66 }) 67 c.Assert(err, IsNil) 68 c.Check(s.systemctlArgs, DeepEquals, [][]string{ 69 {"--root", dirs.GlobalRootDir, "unmask", "systemd-backlight@.service"}, 70 }) 71 } 72 73 func (s *backlightSuite) TestFilesystemOnlyApply(c *C) { 74 conf := configcore.PlainCoreConfig(map[string]interface{}{ 75 "system.disable-backlight-service": "true", 76 }) 77 tmpDir := c.MkDir() 78 c.Assert(configcore.FilesystemOnlyApply(coreDev, tmpDir, conf), IsNil) 79 80 c.Check(s.systemctlArgs, DeepEquals, [][]string{ 81 {"--root", tmpDir, "mask", "systemd-backlight@.service"}, 82 }) 83 }