Пример #1
0
import (
	"encoding/base64"
	"net/url"
	"os"
	"testing"

	chk "github.com/Azure/azure-sdk-for-go/Godeps/_workspace/src/gopkg.in/check.v1"
)

// Hook up gocheck to testing
func Test(t *testing.T) { chk.TestingT(t) }

type StorageClientSuite struct{}

var _ = chk.Suite(&StorageClientSuite{})

// getBasicClient returns a test client from storage credentials in the env
func getBasicClient(c *chk.C) Client {
	name := os.Getenv("ACCOUNT_NAME")
	if name == "" {
		c.Fatal("ACCOUNT_NAME not set, need an empty storage account to test")
	}
	key := os.Getenv("ACCOUNT_KEY")
	if key == "" {
		c.Fatal("ACCOUNT_KEY not set")
	}
	cli, err := NewBasicClient(name, key)
	c.Assert(err, chk.IsNil)
	return cli
}
Пример #2
0
package storage

import (
	"time"

	chk "github.com/Azure/azure-sdk-for-go/Godeps/_workspace/src/gopkg.in/check.v1"
)

type StorageQueueSuite struct{}

var _ = chk.Suite(&StorageQueueSuite{})

func getQueueClient(c *chk.C) QueueServiceClient {
	return getBasicClient(c).GetQueueService()
}

func (s *StorageQueueSuite) Test_pathForQueue(c *chk.C) {
	c.Assert(pathForQueue("q"), chk.Equals, "/q")
}

func (s *StorageQueueSuite) Test_pathForQueueMessages(c *chk.C) {
	c.Assert(pathForQueueMessages("q"), chk.Equals, "/q/messages")
}

func (s *StorageQueueSuite) Test_pathForMessage(c *chk.C) {
	c.Assert(pathForMessage("q", "m"), chk.Equals, "/q/messages/m")
}

func (s *StorageQueueSuite) TestCreateQueue_DeleteQueue(c *chk.C) {
	cli := getQueueClient(c)
	name := randString(20)
Пример #3
0
	"fmt"
	"io"
	"io/ioutil"
	"net/http"
	"net/url"
	"sort"
	"sync"
	"testing"
	"time"

	chk "github.com/Azure/azure-sdk-for-go/Godeps/_workspace/src/gopkg.in/check.v1"
)

type StorageBlobSuite struct{}

var _ = chk.Suite(&StorageBlobSuite{})

const testContainerPrefix = "zzzztest-"

func getBlobClient(c *chk.C) BlobStorageClient {
	return getBasicClient(c).GetBlobService()
}

func (s *StorageBlobSuite) Test_pathForContainer(c *chk.C) {
	c.Assert(pathForContainer("foo"), chk.Equals, "/foo")
}

func (s *StorageBlobSuite) Test_pathForBlob(c *chk.C) {
	c.Assert(pathForBlob("foo", "blob"), chk.Equals, "/foo/blob")
}
Пример #4
0
package storage

import (
	chk "github.com/Azure/azure-sdk-for-go/Godeps/_workspace/src/gopkg.in/check.v1"
)

type StorageFileSuite struct{}

var _ = chk.Suite(&StorageFileSuite{})

func getFileClient(c *chk.C) FileServiceClient {
	return getBasicClient(c).GetFileService()
}

func (s *StorageFileSuite) Test_pathForFileShare(c *chk.C) {
	c.Assert(pathForFileShare("foo"), chk.Equals, "/foo")
}

func (s *StorageFileSuite) TestCreateShareDeleteShare(c *chk.C) {
	cli := getFileClient(c)
	name := randShare()
	c.Assert(cli.CreateShare(name), chk.IsNil)
	c.Assert(cli.DeleteShare(name), chk.IsNil)
}

func (s *StorageFileSuite) TestCreateShareIfNotExists(c *chk.C) {
	cli := getFileClient(c)
	name := randShare()
	defer cli.DeleteShare(name)

	// First create