github.com/axw/juju@v0.0.0-20161005053422-4bd6544d08d4/provider/azure/internal/azuretesting/storage.go (about)

     1  // Copyright 2015 Canonical Ltd.
     2  // Licensed under the AGPLv3, see LICENCE file for details.
     3  
     4  package azuretesting
     5  
     6  import (
     7  	"github.com/Azure/azure-sdk-for-go/storage"
     8  	"github.com/juju/testing"
     9  
    10  	"github.com/juju/juju/provider/azure/internal/azurestorage"
    11  )
    12  
    13  type MockStorageClient struct {
    14  	testing.Stub
    15  
    16  	ListBlobsFunc          func(container string, _ storage.ListBlobsParameters) (storage.BlobListResponse, error)
    17  	DeleteBlobIfExistsFunc func(container, name string) (bool, error)
    18  }
    19  
    20  // NewClient exists to satisfy users who want a NewClientFunc.
    21  func (c *MockStorageClient) NewClient(
    22  	accountName, accountKey, blobServiceBaseURL, apiVersion string,
    23  	useHTTPS bool,
    24  ) (azurestorage.Client, error) {
    25  	c.AddCall("NewClient", accountName, accountKey, blobServiceBaseURL, apiVersion, useHTTPS)
    26  	return c, c.NextErr()
    27  }
    28  
    29  func (c *MockStorageClient) GetBlobService() azurestorage.BlobStorageClient {
    30  	return c
    31  }
    32  
    33  func (c *MockStorageClient) ListBlobs(
    34  	container string,
    35  	params storage.ListBlobsParameters,
    36  ) (storage.BlobListResponse, error) {
    37  	c.MethodCall(c, "ListBlobs", container, params)
    38  	if c.ListBlobsFunc != nil {
    39  		return c.ListBlobsFunc(container, params)
    40  	}
    41  	return storage.BlobListResponse{}, c.NextErr()
    42  }
    43  
    44  func (c *MockStorageClient) DeleteBlobIfExists(container, name string, headers map[string]string) (bool, error) {
    45  	c.MethodCall(c, "DeleteBlobIfExists", container, name)
    46  	if c.DeleteBlobIfExistsFunc != nil {
    47  		return c.DeleteBlobIfExistsFunc(container, name)
    48  	}
    49  	return false, c.NextErr()
    50  }