github.com/stolowski/snapd@v0.0.0-20210407085831-115137ce5a22/image/export_test.go (about) 1 // -*- Mode: Go; indent-tabs-mode: t -*- 2 3 /* 4 * Copyright (C) 2016-2017 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 image 21 22 import ( 23 "github.com/snapcore/snapd/gadget" 24 "github.com/snapcore/snapd/overlord/auth" 25 "github.com/snapcore/snapd/store" 26 ) 27 28 func MockToolingStore(sto Store) *ToolingStore { 29 return &ToolingStore{sto: sto} 30 } 31 32 var ( 33 DecodeModelAssertion = decodeModelAssertion 34 MakeLabel = makeLabel 35 SetupSeed = setupSeed 36 InstallCloudConfig = installCloudConfig 37 ) 38 39 func (tsto *ToolingStore) User() *auth.UserState { 40 return tsto.user 41 } 42 43 func ToolingStoreContext() store.DeviceAndAuthContext { 44 return toolingStoreContext{} 45 } 46 47 func (opts *DownloadOptions) Validate() error { 48 return opts.validate() 49 } 50 51 var ( 52 ErrRevisionAndCohort = errRevisionAndCohort 53 ErrPathInBase = errPathInBase 54 55 WriteResolvedContent = writeResolvedContent 56 ) 57 58 func MockWriteResolvedContent(f func(prepareImageDir string, info *gadget.Info, gadgetRoot, kernelRoot string) error) (restore func()) { 59 oldWriteResolvedContent := writeResolvedContent 60 writeResolvedContent = f 61 return func() { 62 writeResolvedContent = oldWriteResolvedContent 63 } 64 }