Esempio n. 1
0
var amazon = flag.Bool("amazon", false, "Enable tests against amazon server")

// AmazonServer represents an Amazon AWS server.
type AmazonServer struct {
	auth aws.Auth
}

func (s *AmazonServer) SetUp(c *gocheck.C) {
	auth, err := aws.EnvAuth()
	if err != nil {
		c.Fatal(err)
	}
	s.auth = auth
}

var _ = gocheck.Suite(&AmazonClientSuite{})

// AmazonClientSuite tests the client against a live AWS server.
type AmazonClientSuite struct {
	srv AmazonServer
	ClientTests
}

// ClientTests defines integration tests designed to test the client.
// It is not used as a test suite in itself, but embedded within
// another type.
type ClientTests struct {
	elb *elb.ELB
	ec2 *ec2.EC2
}
Esempio n. 2
0
)

// AmazonServer represents an Amazon S3 server.
type AmazonServer struct {
	auth aws.Auth
}

func (s *AmazonServer) SetUp(c *gocheck.C) {
	auth, err := aws.EnvAuth()
	if err != nil {
		c.Fatal(err.Error())
	}
	s.auth = auth
}

var _ = gocheck.Suite(&AmazonClientSuite{Region: aws.USEast})
var _ = gocheck.Suite(&AmazonClientSuite{Region: aws.EUWest})
var _ = gocheck.Suite(&AmazonDomainClientSuite{Region: aws.USEast})

// AmazonClientSuite tests the client against a live S3 server.
type AmazonClientSuite struct {
	aws.Region
	srv AmazonServer
	ClientTests
}

func (s *AmazonClientSuite) SetUpSuite(c *gocheck.C) {
	if !testutil.Amazon {
		c.Skip("live tests against AWS disabled (no -amazon)")
	}
	s.srv.SetUp(c)
Esempio n. 3
0
package dynamodb_test

import (
	simplejson "github.com/bitly/go-simplejson"
	"github.com/goamz/goamz/aws"
	"github.com/goamz/goamz/dynamodb"
	"github.com/motain/gocheck"
)

type QueryBuilderSuite struct {
	server *dynamodb.Server
}

var _ = gocheck.Suite(&QueryBuilderSuite{})

func (s *QueryBuilderSuite) SetUpSuite(c *gocheck.C) {
	auth := &aws.Auth{AccessKey: "", SecretKey: "wJalrXUtnFEMI/K7MDENG+bPxRfiCYEXAMPLEKEY"}
	s.server = &dynamodb.Server{*auth, aws.USEast}
}

func (s *QueryBuilderSuite) TestEmptyQuery(c *gocheck.C) {
	q := dynamodb.NewEmptyQuery()
	queryString := q.String()
	expectedString := "{}"
	c.Check(queryString, gocheck.Equals, expectedString)

	if expectedString != queryString {
		c.Fatalf("Unexpected Query String : %s\n", queryString)
	}
}
Esempio n. 4
0
package ec2_test

import (
	"github.com/heatxsink/goamz/aws"
	"github.com/heatxsink/goamz/ec2"
	"github.com/heatxsink/goamz/testutil"
	"github.com/motain/gocheck"
	"testing"
)

func Test(t *testing.T) {
	gocheck.TestingT(t)
}

var _ = gocheck.Suite(&S{})

type S struct {
	ec2 *ec2.EC2
}

var testServer = testutil.NewHTTPServer()

func (s *S) SetUpSuite(c *gocheck.C) {
	testServer.Start()
	auth := aws.Auth{AccessKey: "abc", SecretKey: "123"}
	s.ec2 = ec2.NewWithClient(
		auth,
		aws.Region{EC2Endpoint: testServer.URL},
		testutil.DefaultClient,
	)
}
Esempio n. 5
0
		AttributeDefinitions: []dynamodb.AttributeDefinitionT{
			dynamodb.AttributeDefinitionT{"TestHashKey", "S"},
			dynamodb.AttributeDefinitionT{"TestRangeKey", "N"},
		},
		KeySchema: []dynamodb.KeySchemaT{
			dynamodb.KeySchemaT{"TestHashKey", "HASH"},
			dynamodb.KeySchemaT{"TestRangeKey", "RANGE"},
		},
		ProvisionedThroughput: dynamodb.ProvisionedThroughputT{
			ReadCapacityUnits:  1,
			WriteCapacityUnits: 1,
		},
	},
}

var _ = gocheck.Suite(table_suite)

func (s *TableSuite) TestCreateListTable(c *gocheck.C) {
	status, err := s.server.CreateTable(s.TableDescriptionT)
	if err != nil {
		c.Fatal(err)
	}
	if status != "ACTIVE" && status != "CREATING" {
		c.Error("Expect status to be ACTIVE or CREATING")
	}

	s.WaitUntilStatus(c, "ACTIVE")

	tables, err := s.server.ListTables()
	if err != nil {
		c.Fatal(err)
Esempio n. 6
0
package aws_test

import (
	"fmt"
	"github.com/flyinprogrammer/ec2metaproxy/Godeps/_workspace/src/github.com/goamz/goamz/aws"
	"github.com/motain/gocheck"
	"net/http"
	"strings"
	"time"
)

var _ = gocheck.Suite(&V4SignerSuite{})

type V4SignerSuite struct {
	auth   aws.Auth
	region aws.Region
	cases  []V4SignerSuiteCase
}

type V4SignerSuiteCase struct {
	label            string
	request          V4SignerSuiteCaseRequest
	canonicalRequest string
	stringToSign     string
	signature        string
	authorization    string
}

type V4SignerSuiteCaseRequest struct {
	method  string
	host    string
Esempio n. 7
0
		dynamodb.Attribute{Type: "N", Name: "TestInt", Value: "-99", SetValues: []string(nil)},
		dynamodb.Attribute{Type: "N", Name: "TestInt32", Value: "999", SetValues: []string(nil)},
		dynamodb.Attribute{Type: "N", Name: "TestInt64", Value: "9999", SetValues: []string(nil)},
		dynamodb.Attribute{Type: "N", Name: "TestUint", Value: "99", SetValues: []string(nil)},
		dynamodb.Attribute{Type: "N", Name: "TestFloat32", Value: "9.9999", SetValues: []string(nil)},
		dynamodb.Attribute{Type: "N", Name: "TestFloat64", Value: "99.999999", SetValues: []string(nil)},
		dynamodb.Attribute{Type: "S", Name: "TestString", Value: "test", SetValues: []string(nil)},
		dynamodb.Attribute{Type: "S", Name: "TestByteArray", Value: "Ynl0ZXM=", SetValues: []string(nil)},
		dynamodb.Attribute{Type: "S", Name: "TestSub", Value: `{"SubBool":true,"SubInt":2,"SubString":"subtest","SubStringArray":["sub1","sub2","sub3"]}`, SetValues: []string(nil)},
	}
}

type MarshallerSuite struct {
}

var _ = gocheck.Suite(&MarshallerSuite{})

func (s *MarshallerSuite) TestMarshal(c *gocheck.C) {
	testObj := testObject()
	attrs, err := dynamodb.MarshalAttributes(testObj)
	if err != nil {
		c.Errorf("Error from dynamodb.MarshalAttributes: %#v", err)
	}

	expected := testAttrs()
	c.Check(attrs, gocheck.DeepEquals, expected)
}

func (s *MarshallerSuite) TestUnmarshal(c *gocheck.C) {
	testObj := &TestStruct{}
Esempio n. 8
0
package container

import (
	"testing"

	gc "github.com/motain/gocheck"
)

var _ = gc.Suite(&ContainerBagSuite{})

type ContainerBagSuite struct{}

// Hook up gocheck into the "go test" runner.
func Test(t *testing.T) { gc.TestingT(t) }

func (s *ContainerBagSuite) TestNewContainerBagMustInitializeComponentsIfConfigProvided(c *gc.C) {
	c.Skip("todo")
}

func (s *ContainerBagSuite) TestNewContainerShouldReturnProperHashedUrl(c *gc.C) {
	c.Skip("todo")
}

func (s *ContainerBagSuite) TestNewContainerShouldSetFilterForValidRegex(c *gc.C) {
	c.Skip("todo")
}

func (s *ContainerBagSuite) TestNewContainerShouldNotSetFilterForInvalidRegex(c *gc.C) {
	c.Skip("todo")
}
Esempio n. 9
0
// ServerTests defines a set of tests designed to test
// the elbtest local fake elb server.
// It is not used as a test suite in itself, but embedded within
// another type.
type ServerTests struct {
	elb *elb.ELB
}

// AmazonServerSuite runs the elbtest server tests against a live ELB server.
// It will only be activated if the -all flag is specified.
type AmazonServerSuite struct {
	srv AmazonServer
	ServerTests
}

var _ = gocheck.Suite(&AmazonServerSuite{})

func (s *AmazonServerSuite) SetUpSuite(c *gocheck.C) {
	if !*amazon {
		c.Skip("AmazonServerSuite tests not enabled")
	}
	s.srv.SetUp(c)
	s.ServerTests.elb = elb.New(s.srv.auth, aws.USEast)
}

var _ = gocheck.Suite(&LocalServerSuite{})

func (s *LocalServerSuite) SetUpSuite(c *gocheck.C) {
	s.srv.SetUp(c)
	s.ServerTests.elb = elb.New(s.srv.auth, s.srv.region)
	s.clientTests.elb = elb.New(s.srv.auth, s.srv.region)
Esempio n. 10
0
// LocalServer represents a local ec2test fake server.
type LocalServer struct {
	auth   aws.Auth
	region aws.Region
	srv    *iamtest.Server
}

func (s *LocalServer) SetUp(c *gocheck.C) {
	srv, err := iamtest.NewServer()
	c.Assert(err, gocheck.IsNil)
	c.Assert(srv, gocheck.NotNil)

	s.srv = srv
	s.region = aws.Region{IAMEndpoint: srv.URL()}
}

// LocalServerSuite defines tests that will run
// against the local iamtest server. It includes
// tests from ClientTests.
type LocalServerSuite struct {
	srv LocalServer
	ClientTests
}

var _ = gocheck.Suite(&LocalServerSuite{})

func (s *LocalServerSuite) SetUpSuite(c *gocheck.C) {
	s.srv.SetUp(c)
	s.ClientTests.iam = iam.New(s.srv.auth, s.srv.region)
}
Esempio n. 11
0
		TableName: "DynamoDBTestMyTable",
		AttributeDefinitions: []dynamodb.AttributeDefinitionT{
			dynamodb.AttributeDefinitionT{"TestHashKey", "S"},
		},
		KeySchema: []dynamodb.KeySchemaT{
			dynamodb.KeySchemaT{"TestHashKey", "HASH"},
		},
		ProvisionedThroughput: dynamodb.ProvisionedThroughputT{
			ReadCapacityUnits:  1,
			WriteCapacityUnits: 1,
		},
	},
	WithRange: false,
}

var _ = gocheck.Suite(item_suite)
var _ = gocheck.Suite(item_without_range_suite)

func (s *ItemSuite) TestConditionalPutUpdateDeleteItem(c *gocheck.C) {
	if s.WithRange {
		// No rangekey test required
		return
	}

	attrs := []dynamodb.Attribute{
		*dynamodb.NewStringAttribute("Attr1", "Attr1Val"),
	}
	pk := &dynamodb.Key{HashKey: "NewHashKeyVal"}

	// Put
	if ok, err := s.table.PutItem("NewHashKeyVal", "", attrs); !ok {
Esempio n. 12
0
package cache

import (
	"testing"

	gc "github.com/motain/gocheck"
)

var _ = gc.Suite(&CacheSuite{})

type CacheSuite struct{}

// Hook up gocheck into the "go test" runner.
func Test(t *testing.T) { gc.TestingT(t) }

func (s *CacheSuite) TestSetCacheShouldCreateFile(c *gc.C) {
	c.Skip("todo")
}

func (s *CacheSuite) TestNonExistingKeyShouldReturnError(c *gc.C) {
	c.Skip("todo")
}

func (s *CacheSuite) TestExistingCacheShouldReturnData(c *gc.C) {
	c.Skip("todo")
}

func (s *CacheSuite) TestExpiredTimeShouldReturnError(c *gc.C) {
	c.Skip("todo")
}
Esempio n. 13
0
package handler

import (
	"testing"

	gc "github.com/motain/gocheck"
)

var _ = gc.Suite(&HandlerSuite{})

type HandlerSuite struct{}

// Hook up gocheck into the "go test" runner.
func Test(t *testing.T) { gc.TestingT(t) }

func (s *HandlerSuite) TestIndexMustReturnOK(c *gc.C) {
	c.Skip("todo")
}

func (s *HandlerSuite) TestGetBuildersMustReturnListOfBuilders(c *gc.C) {
	c.Skip("todo: to make this test work, we will have to separate the 'buildbot' into a entitiy, and make it an interface, mockable, so we can mock the idea of request the list")
}

func (s *HandlerSuite) TestGetSingleBuilderMustReturnBuilder(c *gc.C) {
	c.Skip("todo")
}
Esempio n. 14
0
package config

import (
	"testing"

	gc "github.com/motain/gocheck"
)

var _ = gc.Suite(&ConfigSuite{})

type ConfigSuite struct{}

// Hook up gocheck into the "go test" runner.
func Test(t *testing.T) { gc.TestingT(t) }

func (s *ConfigSuite) TestNewConfigShouldReturnErrorIfNoBuildBot(c *gc.C) {
	cfg, err := NewConfig()

	c.Check(err, gc.NotNil)
	c.Check(cfg, gc.IsNil)
}
Esempio n. 15
0
	}
}

// LocalServerSuite defines tests that will run
// against the local s3test server. It includes
// selected tests from ClientTests;
// when the s3test functionality is sufficient, it should
// include all of them, and ClientTests can be simply embedded.
type LocalServerSuite struct {
	srv         LocalServer
	clientTests ClientTests
}

var (
	// run tests twice, once in us-east-1 mode, once not.
	_ = gocheck.Suite(&LocalServerSuite{})
	_ = gocheck.Suite(&LocalServerSuite{
		srv: LocalServer{
			config: &s3test.Config{
				Send409Conflict: true,
			},
		},
	})
)

func (s *LocalServerSuite) SetUpSuite(c *gocheck.C) {
	s.srv.SetUp(c)
	s.clientTests.s3 = s3.New(s.srv.auth, s.srv.region)

	// TODO Sadly the fake server ignores auth completely right now. :-(
	s.clientTests.authIsBroken = true