本文整理匯總了Golang中github.com/motain/gocheck.C.Fatal方法的典型用法代碼示例。如果您正苦於以下問題:Golang C.Fatal方法的具體用法?Golang C.Fatal怎麽用?Golang C.Fatal使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/motain/gocheck.C
的用法示例。
在下文中一共展示了C.Fatal方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: WaitUntilStatus
func (s *DynamoDBTest) WaitUntilStatus(c *gocheck.C, status string) {
// We should wait until the table is in specified status because a real DynamoDB has some delay for ready
done := make(chan bool)
timeout := time.After(TIMEOUT)
go func() {
for {
select {
case <-done:
return
default:
desc, err := s.table.DescribeTable()
if err != nil {
c.Fatal(err)
}
if desc.TableStatus == status {
done <- true
return
}
time.Sleep(5 * time.Second)
}
}
}()
select {
case <-done:
break
case <-timeout:
c.Errorf("Expect a status to be %s, but timed out", status)
close(done)
}
}
示例2: SetUp
func (s *AmazonServer) SetUp(c *gocheck.C) {
auth, err := aws.EnvAuth()
if err != nil {
c.Fatal(err.Error())
}
s.auth = auth
}
示例3: SetUpSuite
func (s *SuiteI) SetUpSuite(c *gocheck.C) {
if !*integration {
c.Skip("Integration tests not enabled (-i flag)")
}
auth, err := aws.EnvAuth()
if err != nil {
c.Fatal(err.Error())
}
s.auth = auth
}
示例4: SetUpSuite
func (s *LiveSuite) SetUpSuite(c *gocheck.C) {
if !Amazon {
c.Skip("amazon tests not enabled (-amazon flag)")
}
auth, err := aws.EnvAuth()
if err != nil {
c.Fatal(err.Error())
}
s.auth = auth
}
示例5: TestAddKeyConditions
func (s *QueryBuilderSuite) TestAddKeyConditions(c *gocheck.C) {
primary := dynamodb.NewStringAttribute("domain", "")
key := dynamodb.PrimaryKey{primary, nil}
table := s.server.NewTable("sites", key)
q := dynamodb.NewQuery(table)
acs := []dynamodb.AttributeComparison{
*dynamodb.NewStringAttributeComparison("domain", "EQ", "example.com"),
*dynamodb.NewStringAttributeComparison("path", "EQ", "/"),
}
q.AddKeyConditions(acs)
queryJson, err := simplejson.NewJson([]byte(q.String()))
if err != nil {
c.Fatal(err)
}
expectedJson, err := simplejson.NewJson([]byte(`
{
"KeyConditions": {
"domain": {
"AttributeValueList": [
{
"S": "example.com"
}
],
"ComparisonOperator": "EQ"
},
"path": {
"AttributeValueList": [
{
"S": "/"
}
],
"ComparisonOperator": "EQ"
}
},
"TableName": "sites"
}
`))
if err != nil {
c.Fatal(err)
}
c.Check(queryJson, gocheck.DeepEquals, expectedJson)
}
示例6: TestGetItemQuery
func (s *QueryBuilderSuite) TestGetItemQuery(c *gocheck.C) {
primary := dynamodb.NewStringAttribute("domain", "")
key := dynamodb.PrimaryKey{primary, nil}
table := s.server.NewTable("sites", key)
q := dynamodb.NewQuery(table)
q.AddKey(table, &dynamodb.Key{HashKey: "test"})
{
queryJson, err := simplejson.NewJson([]byte(q.String()))
if err != nil {
c.Fatal(err)
}
expectedJson, err := simplejson.NewJson([]byte(`
{
"Key": {
"domain": {
"S": "test"
}
},
"TableName": "sites"
}
`))
if err != nil {
c.Fatal(err)
}
c.Check(queryJson, gocheck.DeepEquals, expectedJson)
}
// Use ConsistentRead
{
q.ConsistentRead(true)
queryJson, err := simplejson.NewJson([]byte(q.String()))
if err != nil {
c.Fatal(err)
}
expectedJson, err := simplejson.NewJson([]byte(`
{
"ConsistentRead": "true",
"Key": {
"domain": {
"S": "test"
}
},
"TableName": "sites"
}
`))
if err != nil {
c.Fatal(err)
}
c.Check(queryJson, gocheck.DeepEquals, expectedJson)
}
}
示例7: TestAddExpectedQuery
func (s *QueryBuilderSuite) TestAddExpectedQuery(c *gocheck.C) {
primary := dynamodb.NewStringAttribute("domain", "")
key := dynamodb.PrimaryKey{primary, nil}
table := s.server.NewTable("sites", key)
q := dynamodb.NewQuery(table)
q.AddKey(table, &dynamodb.Key{HashKey: "test"})
expected := []dynamodb.Attribute{
*dynamodb.NewStringAttribute("domain", "expectedTest").SetExists(true),
*dynamodb.NewStringAttribute("testKey", "").SetExists(false),
}
q.AddExpected(expected)
queryJson, err := simplejson.NewJson([]byte(q.String()))
if err != nil {
c.Fatal(err)
}
expectedJson, err := simplejson.NewJson([]byte(`
{
"Expected": {
"domain": {
"Exists": "true",
"Value": {
"S": "expectedTest"
}
},
"testKey": {
"Exists": "false"
}
},
"Key": {
"domain": {
"S": "test"
}
},
"TableName": "sites"
}
`))
if err != nil {
c.Fatal(err)
}
c.Check(queryJson, gocheck.DeepEquals, expectedJson)
}
示例8: setUpAuth
func setUpAuth(c *gocheck.C) {
if !*amazon {
c.Skip("Test against amazon not enabled.")
}
if *local {
c.Log("Using local server")
dynamodb_region = aws.Region{DynamoDBEndpoint: "http://127.0.0.1:8000"}
dynamodb_auth = aws.Auth{AccessKey: "DUMMY_KEY", SecretKey: "DUMMY_SECRET"}
} else {
c.Log("Using REAL AMAZON SERVER")
dynamodb_region = aws.USEast
auth, err := aws.EnvAuth()
if err != nil {
c.Fatal(err)
}
dynamodb_auth = auth
}
}
示例9: SetUpSuite
func (s *ItemSuite) SetUpSuite(c *gocheck.C) {
setUpAuth(c)
s.DynamoDBTest.TableDescriptionT = s.TableDescriptionT
s.server = &dynamodb.Server{dynamodb_auth, dynamodb_region}
pk, err := s.TableDescriptionT.BuildPrimaryKey()
if err != nil {
c.Skip(err.Error())
}
s.table = s.server.NewTable(s.TableDescriptionT.TableName, pk)
// Cleanup
s.TearDownSuite(c)
_, err = s.server.CreateTable(s.TableDescriptionT)
if err != nil {
c.Fatal(err)
}
s.WaitUntilStatus(c, "ACTIVE")
}
示例10: TestCreateListTable
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)
}
c.Check(len(tables), gocheck.Not(gocheck.Equals), 0)
c.Check(findTableByName(tables, s.TableDescriptionT.TableName), gocheck.Equals, true)
}
示例11: TestUpdateQuery
func (s *QueryBuilderSuite) TestUpdateQuery(c *gocheck.C) {
primary := dynamodb.NewStringAttribute("domain", "")
rangek := dynamodb.NewNumericAttribute("time", "")
key := dynamodb.PrimaryKey{primary, rangek}
table := s.server.NewTable("sites", key)
countAttribute := dynamodb.NewNumericAttribute("count", "4")
attributes := []dynamodb.Attribute{*countAttribute}
q := dynamodb.NewQuery(table)
q.AddKey(table, &dynamodb.Key{HashKey: "test", RangeKey: "1234"})
q.AddUpdates(attributes, "ADD")
queryJson, err := simplejson.NewJson([]byte(q.String()))
if err != nil {
c.Fatal(err)
}
expectedJson, err := simplejson.NewJson([]byte(`
{
"AttributeUpdates": {
"count": {
"Action": "ADD",
"Value": {
"N": "4"
}
}
},
"Key": {
"domain": {
"S": "test"
},
"time": {
"N": "1234"
}
},
"TableName": "sites"
}
`))
if err != nil {
c.Fatal(err)
}
c.Check(queryJson, gocheck.DeepEquals, expectedJson)
}
示例12: TestAddUpdates
func (s *QueryBuilderSuite) TestAddUpdates(c *gocheck.C) {
primary := dynamodb.NewStringAttribute("domain", "")
key := dynamodb.PrimaryKey{primary, nil}
table := s.server.NewTable("sites", key)
q := dynamodb.NewQuery(table)
q.AddKey(table, &dynamodb.Key{HashKey: "test"})
attr := dynamodb.NewStringSetAttribute("StringSet", []string{"str", "str2"})
q.AddUpdates([]dynamodb.Attribute{*attr}, "ADD")
queryJson, err := simplejson.NewJson([]byte(q.String()))
if err != nil {
c.Fatal(err)
}
expectedJson, err := simplejson.NewJson([]byte(`
{
"AttributeUpdates": {
"StringSet": {
"Action": "ADD",
"Value": {
"SS": ["str", "str2"]
}
}
},
"Key": {
"domain": {
"S": "test"
}
},
"TableName": "sites"
}
`))
if err != nil {
c.Fatal(err)
}
c.Check(queryJson, gocheck.DeepEquals, expectedJson)
}
示例13: TearDownSuite
func (s *DynamoDBTest) TearDownSuite(c *gocheck.C) {
// return immediately in the case of calling c.Skip() in SetUpSuite()
if s.server == nil {
return
}
// check whether the table exists
if tables, err := s.server.ListTables(); err != nil {
c.Fatal(err)
} else {
if !findTableByName(tables, s.TableDescriptionT.TableName) {
return
}
}
// Delete the table and wait
if _, err := s.server.DeleteTable(s.TableDescriptionT); err != nil {
c.Fatal(err)
}
done := make(chan bool)
timeout := time.After(TIMEOUT)
go func() {
for {
select {
case <-done:
return
default:
tables, err := s.server.ListTables()
if err != nil {
c.Fatal(err)
}
if findTableByName(tables, s.TableDescriptionT.TableName) {
time.Sleep(5 * time.Second)
} else {
done <- true
return
}
}
}
}()
select {
case <-done:
break
case <-timeout:
c.Error("Expect the table to be deleted but timed out")
close(done)
}
}
示例14: TestPutGetDeleteItem
func (s *ItemSuite) TestPutGetDeleteItem(c *gocheck.C) {
attrs := []dynamodb.Attribute{
*dynamodb.NewStringAttribute("Attr1", "Attr1Val"),
}
var rk string
if s.WithRange {
rk = "1"
}
// Put
if ok, err := s.table.PutItem("NewHashKeyVal", rk, attrs); !ok {
c.Fatal(err)
}
// Get to verify Put operation
pk := &dynamodb.Key{HashKey: "NewHashKeyVal", RangeKey: rk}
item, err := s.table.GetItem(pk)
if err != nil {
c.Fatal(err)
}
if val, ok := item["TestHashKey"]; ok {
c.Check(val, gocheck.DeepEquals, dynamodb.NewStringAttribute("TestHashKey", "NewHashKeyVal"))
} else {
c.Error("Expect TestHashKey to be found")
}
if s.WithRange {
if val, ok := item["TestRangeKey"]; ok {
c.Check(val, gocheck.DeepEquals, dynamodb.NewNumericAttribute("TestRangeKey", "1"))
} else {
c.Error("Expect TestRangeKey to be found")
}
}
// Delete
if ok, _ := s.table.DeleteItem(pk); !ok {
c.Fatal(err)
}
// Get to verify Delete operation
_, err = s.table.GetItem(pk)
c.Check(err.Error(), gocheck.Matches, "Item not found")
}
示例15: TearDownTest
// Delete all items in the table
func (s *DynamoDBTest) TearDownTest(c *gocheck.C) {
pk, err := s.TableDescriptionT.BuildPrimaryKey()
if err != nil {
c.Fatal(err)
}
attrs, err := s.table.Scan(nil)
if err != nil {
c.Fatal(err)
}
for _, a := range attrs {
key := &dynamodb.Key{
HashKey: a[pk.KeyAttribute.Name].Value,
}
if pk.HasRange() {
key.RangeKey = a[pk.RangeAttribute.Name].Value
}
if ok, err := s.table.DeleteItem(key); !ok {
c.Fatal(err)
}
}
}