github.com/wallyworld/juju@v0.0.0-20161013125918-6cf1bc9d917a/resource/api/private/server/stub_test.go (about)

     1  // Copyright 2016 Canonical Ltd.
     2  // Licensed under the AGPLv3, see LICENCE file for details.
     3  
     4  package server_test
     5  
     6  import (
     7  	"io"
     8  
     9  	"github.com/juju/errors"
    10  	"github.com/juju/testing"
    11  
    12  	"github.com/juju/juju/resource"
    13  )
    14  
    15  type stubUnitDataStore struct {
    16  	*testing.Stub
    17  
    18  	ReturnOpenResource  resource.Opened
    19  	ReturnGetResource   resource.Resource
    20  	ReturnListResources resource.ServiceResources
    21  }
    22  
    23  func (s *stubUnitDataStore) OpenResource(name string) (resource.Resource, io.ReadCloser, error) {
    24  	s.AddCall("OpenResource", name)
    25  	if err := s.NextErr(); err != nil {
    26  		return resource.Resource{}, nil, errors.Trace(err)
    27  	}
    28  
    29  	return s.ReturnOpenResource.Resource, s.ReturnOpenResource.ReadCloser, nil
    30  }
    31  
    32  func (s *stubUnitDataStore) GetResource(name string) (resource.Resource, error) {
    33  	s.AddCall("GetResource", name)
    34  	if err := s.NextErr(); err != nil {
    35  		return resource.Resource{}, errors.Trace(err)
    36  	}
    37  
    38  	return s.ReturnGetResource, nil
    39  }
    40  
    41  func (s *stubUnitDataStore) ListResources() (resource.ServiceResources, error) {
    42  	s.AddCall("ListResources")
    43  	if err := s.NextErr(); err != nil {
    44  		return resource.ServiceResources{}, errors.Trace(err)
    45  	}
    46  
    47  	return s.ReturnListResources, nil
    48  }