github.com/fawick/restic@v0.1.1-0.20171126184616-c02923fbfc79/internal/mock/repository.go (about)

     1  package mock
     2  
     3  import (
     4  	"github.com/restic/restic/internal/crypto"
     5  	"github.com/restic/restic/internal/restic"
     6  )
     7  
     8  // Repository implements a mock Repository.
     9  type Repository struct {
    10  	BackendFn func() restic.Backend
    11  
    12  	KeyFn func() *crypto.Key
    13  
    14  	SetIndexFn func(restic.Index)
    15  
    16  	IndexFn         func() restic.Index
    17  	SaveFullIndexFn func() error
    18  	SaveIndexFn     func() error
    19  	LoadIndexFn     func() error
    20  
    21  	ConfigFn func() restic.Config
    22  
    23  	LookupBlobSizeFn func(restic.ID, restic.BlobType) (uint, error)
    24  
    25  	ListFn     func(restic.FileType, <-chan struct{}) <-chan restic.ID
    26  	ListPackFn func(restic.ID) ([]restic.Blob, int64, error)
    27  
    28  	FlushFn func() error
    29  
    30  	SaveUnpackedFn     func(restic.FileType, []byte) (restic.ID, error)
    31  	SaveJSONUnpackedFn func(restic.FileType, interface{}) (restic.ID, error)
    32  
    33  	LoadJSONUnpackedFn func(restic.FileType, restic.ID, interface{}) error
    34  	LoadAndDecryptFn   func(restic.FileType, restic.ID) ([]byte, error)
    35  
    36  	LoadBlobFn func(restic.BlobType, restic.ID, []byte) (int, error)
    37  	SaveBlobFn func(restic.BlobType, []byte, restic.ID) (restic.ID, error)
    38  
    39  	LoadTreeFn func(restic.ID) (*restic.Tree, error)
    40  	SaveTreeFn func(t *restic.Tree) (restic.ID, error)
    41  }
    42  
    43  // Backend is a stub method.
    44  func (repo Repository) Backend() restic.Backend {
    45  	return repo.BackendFn()
    46  }
    47  
    48  // Key is a stub method.
    49  func (repo Repository) Key() *crypto.Key {
    50  	return repo.KeyFn()
    51  }
    52  
    53  // SetIndex is a stub method.
    54  func (repo Repository) SetIndex(idx restic.Index) {
    55  	repo.SetIndexFn(idx)
    56  }
    57  
    58  // Index is a stub method.
    59  func (repo Repository) Index() restic.Index {
    60  	return repo.IndexFn()
    61  }
    62  
    63  // SaveFullIndex is a stub method.
    64  func (repo Repository) SaveFullIndex() error {
    65  	return repo.SaveFullIndexFn()
    66  }
    67  
    68  // SaveIndex is a stub method.
    69  func (repo Repository) SaveIndex() error {
    70  	return repo.SaveIndexFn()
    71  }
    72  
    73  // LoadIndex is a stub method.
    74  func (repo Repository) LoadIndex() error {
    75  	return repo.LoadIndexFn()
    76  }
    77  
    78  // Config is a stub method.
    79  func (repo Repository) Config() restic.Config {
    80  	return repo.ConfigFn()
    81  }
    82  
    83  // LookupBlobSize is a stub method.
    84  func (repo Repository) LookupBlobSize(id restic.ID, t restic.BlobType) (uint, error) {
    85  	return repo.LookupBlobSizeFn(id, t)
    86  }
    87  
    88  // List is a stub method.
    89  func (repo Repository) List(t restic.FileType, done <-chan struct{}) <-chan restic.ID {
    90  	return repo.ListFn(t, done)
    91  }
    92  
    93  // ListPack is a stub method.
    94  func (repo Repository) ListPack(id restic.ID) ([]restic.Blob, int64, error) {
    95  	return repo.ListPackFn(id)
    96  }
    97  
    98  // Flush is a stub method.
    99  func (repo Repository) Flush() error {
   100  	return repo.FlushFn()
   101  }
   102  
   103  // SaveUnpacked is a stub method.
   104  func (repo Repository) SaveUnpacked(t restic.FileType, buf []byte) (restic.ID, error) {
   105  	return repo.SaveUnpackedFn(t, buf)
   106  }
   107  
   108  // SaveJSONUnpacked is a stub method.
   109  func (repo Repository) SaveJSONUnpacked(t restic.FileType, item interface{}) (restic.ID, error) {
   110  	return repo.SaveJSONUnpackedFn(t, item)
   111  }
   112  
   113  // LoadJSONUnpacked is a stub method.
   114  func (repo Repository) LoadJSONUnpacked(t restic.FileType, id restic.ID, item interface{}) error {
   115  	return repo.LoadJSONUnpackedFn(t, id, item)
   116  }
   117  
   118  // LoadAndDecrypt is a stub method.
   119  func (repo Repository) LoadAndDecrypt(t restic.FileType, id restic.ID) ([]byte, error) {
   120  	return repo.LoadAndDecryptFn(t, id)
   121  }
   122  
   123  // LoadBlob is a stub method.
   124  func (repo Repository) LoadBlob(t restic.BlobType, id restic.ID, buf []byte) (int, error) {
   125  	return repo.LoadBlobFn(t, id, buf)
   126  }
   127  
   128  // SaveBlob is a stub method.
   129  func (repo Repository) SaveBlob(t restic.BlobType, buf []byte, id restic.ID) (restic.ID, error) {
   130  	return repo.SaveBlobFn(t, buf, id)
   131  }
   132  
   133  // LoadTree is a stub method.
   134  func (repo Repository) LoadTree(id restic.ID) (*restic.Tree, error) {
   135  	return repo.LoadTreeFn(id)
   136  }
   137  
   138  // SaveTree is a stub method.
   139  func (repo Repository) SaveTree(t *restic.Tree) (restic.ID, error) {
   140  	return repo.SaveTreeFn(t)
   141  }