github.com/bugraaydogar/snapd@v0.0.0-20210315170335-8c70bb858939/interfaces/export_test.go (about)

     1  // -*- Mode: Go; indent-tabs-mode: t -*-
     2  
     3  /*
     4   * Copyright (C) 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 interfaces
    21  
    22  type ByConnRef byConnRef
    23  
    24  func (c ByConnRef) Len() int           { return byConnRef(c).Len() }
    25  func (c ByConnRef) Swap(i, j int)      { byConnRef(c).Swap(i, j) }
    26  func (c ByConnRef) Less(i, j int) bool { return byConnRef(c).Less(i, j) }
    27  
    28  type ByPlugSnapAndName byPlugSnapAndName
    29  
    30  func (c ByPlugSnapAndName) Len() int           { return byPlugSnapAndName(c).Len() }
    31  func (c ByPlugSnapAndName) Swap(i, j int)      { byPlugSnapAndName(c).Swap(i, j) }
    32  func (c ByPlugSnapAndName) Less(i, j int) bool { return byPlugSnapAndName(c).Less(i, j) }
    33  
    34  type BySlotSnapAndName bySlotSnapAndName
    35  
    36  func (c BySlotSnapAndName) Len() int           { return bySlotSnapAndName(c).Len() }
    37  func (c BySlotSnapAndName) Swap(i, j int)      { bySlotSnapAndName(c).Swap(i, j) }
    38  func (c BySlotSnapAndName) Less(i, j int) bool { return bySlotSnapAndName(c).Less(i, j) }
    39  
    40  type ByInterfaceName byInterfaceName
    41  
    42  func (c ByInterfaceName) Len() int           { return byInterfaceName(c).Len() }
    43  func (c ByInterfaceName) Swap(i, j int)      { byInterfaceName(c).Swap(i, j) }
    44  func (c ByInterfaceName) Less(i, j int) bool { return byInterfaceName(c).Less(i, j) }
    45  
    46  // MockIsHomeUsingNFS mocks the real implementation of osutil.IsHomeUsingNFS
    47  func MockIsHomeUsingNFS(new func() (bool, error)) (restore func()) {
    48  	old := isHomeUsingNFS
    49  	isHomeUsingNFS = new
    50  	return func() {
    51  		isHomeUsingNFS = old
    52  	}
    53  }
    54  
    55  // MockIsRootWritableOverlay mocks the real implementation of
    56  // osutil.IsRootWritableOverlay
    57  func MockIsRootWritableOverlay(new func() (string, error)) (restore func()) {
    58  	old := isRootWritableOverlay
    59  	isRootWritableOverlay = new
    60  	return func() {
    61  		isRootWritableOverlay = old
    62  	}
    63  }
    64  
    65  func MockReadBuildID(mock func(p string) (string, error)) (restore func()) {
    66  	old := readBuildID
    67  	readBuildID = mock
    68  	return func() {
    69  		readBuildID = old
    70  	}
    71  }
    72  
    73  type SystemKey = systemKey
    74  
    75  var SystemKeyVersion = systemKeyVersion