github.com/anonymouse64/snapd@v0.0.0-20210824153203-04c4c42d842d/gadget/install/export_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 install 21 22 import ( 23 "time" 24 25 "github.com/snapcore/snapd/gadget" 26 ) 27 28 var ( 29 MakeFilesystem = makeFilesystem 30 WriteContent = writeContent 31 MountFilesystem = mountFilesystem 32 33 CreateMissingPartitions = createMissingPartitions 34 BuildPartitionList = buildPartitionList 35 RemoveCreatedPartitions = removeCreatedPartitions 36 EnsureNodesExist = ensureNodesExist 37 38 CreatedDuringInstall = createdDuringInstall 39 CreationSupported = creationSupported 40 ) 41 42 func MockContentMountpoint(new string) (restore func()) { 43 old := contentMountpoint 44 contentMountpoint = new 45 return func() { 46 contentMountpoint = old 47 } 48 } 49 50 func MockSysMount(f func(source, target, fstype string, flags uintptr, data string) error) (restore func()) { 51 old := sysMount 52 sysMount = f 53 return func() { 54 sysMount = old 55 } 56 } 57 58 func MockSysUnmount(f func(target string, flags int) error) (restore func()) { 59 old := sysUnmount 60 sysUnmount = f 61 return func() { 62 sysUnmount = old 63 } 64 } 65 66 func MockEnsureNodesExist(f func(dss []gadget.OnDiskStructure, timeout time.Duration) error) (restore func()) { 67 old := ensureNodesExist 68 ensureNodesExist = f 69 return func() { 70 ensureNodesExist = old 71 } 72 }