github.com/stolowski/snapd@v0.0.0-20210407085831-115137ce5a22/wrappers/export_test.go (about) 1 // -*- Mode: Go; indent-tabs-mode: t -*- 2 3 /* 4 * Copyright (C) 2016 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 wrappers 21 22 import ( 23 "time" 24 25 "github.com/snapcore/snapd/osutil" 26 ) 27 28 // some internal helper exposed for testing 29 var ( 30 // services 31 GenerateSnapServiceFile = generateSnapServiceFile 32 GenerateSnapSocketFiles = generateSnapSocketFiles 33 GenerateSnapTimerFile = generateSnapTimerFile 34 35 // dbus 36 GenerateDBusActivationFile = generateDBusActivationFile 37 38 // desktop 39 SanitizeDesktopFile = sanitizeDesktopFile 40 RewriteExecLine = rewriteExecLine 41 RewriteIconLine = rewriteIconLine 42 IsValidDesktopFileLine = isValidDesktopFileLine 43 44 // timers 45 GenerateOnCalendarSchedules = generateOnCalendarSchedules 46 47 // icons 48 FindIconFiles = findIconFiles 49 ) 50 51 func MockKillWait(wait time.Duration) (restore func()) { 52 oldKillWait := killWait 53 killWait = wait 54 return func() { 55 killWait = oldKillWait 56 } 57 } 58 59 func MockEnsureDirState(f func(dir string, glob string, content map[string]osutil.FileState) (changed, removed []string, err error)) (restore func()) { 60 oldEnsureDirState := ensureDirState 61 ensureDirState = f 62 return func() { 63 ensureDirState = oldEnsureDirState 64 } 65 }