當前位置: 首頁>>代碼示例>>Golang>>正文


Golang test.Fatal函數代碼示例

本文整理匯總了Golang中github.com/Mparaiso/go-tiger/test.Fatal函數的典型用法代碼示例。如果您正苦於以下問題:Golang Fatal函數的具體用法?Golang Fatal怎麽用?Golang Fatal使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了Fatal函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: TestDeleteWithoutAlias

func TestDeleteWithoutAlias(t *testing.T) {
	connection := NewTestConnection(t)
	qb := db.NewQueryBuilder(connection)
	qb.Delete("users")
	test.Fatal(t, db.Delete, qb.GetType())
	test.Fatal(t, "DELETE FROM users", qb.String())
}
開發者ID:Mparaiso,項目名稱:apipress,代碼行數:7,代碼來源:builder_test.go

示例2: TestDocumentManager_Register_StoreIdAnnotation

func TestDocumentManager_Register_StoreIdAnnotation(t *testing.T) {
	type Person struct {
		ID   bson.ObjectId `bson:"_id"`
		Name string        `bson:"Name"`
	}
	type Family struct {
		ID        bson.ObjectId   `bson:"_id"`
		Name      string          `bson:"Name"`
		Members   []*Person       `odm:"referenceMany(targetDocument:Person,storeId:MemberIDs,cascade:all)"`
		MemberIDs []bson.ObjectId `bson:"MemberIDs"`
	}
	dm, done := getDocumentManager(t)
	defer done()
	err := dm.RegisterMany(map[string]interface{}{
		"Person": new(Person),
		"Family": new(Family),
	})
	test.Fatal(t, err, nil)
	family := &Family{Name: "Doe", Members: []*Person{{Name: "John"}, {Name: "Jane"}, {Name: "Jack"}}}
	dm.Persist(family)
	err = dm.Flush()
	test.Fatal(t, err, nil)
	family = new(Family)
	err = dm.FindOne(bson.M{"Name": "Doe"}, family)
	test.Fatal(t, err, nil)
	test.Fatal(t, len(family.MemberIDs), 3)
}
開發者ID:Mparaiso,項目名稱:apipress,代碼行數:27,代碼來源:mongo_test.go

示例3: TestSetFirstResult

func TestSetFirstResult(t *testing.T) {
	connection := NewTestConnection(t)
	qb := db.NewQueryBuilder(connection)
	qb.SetFirstResult(10)
	test.Fatal(t, qb.GetState(), db.Dirty)
	test.Fatal(t, qb.GetFirstResult(), 10)
}
開發者ID:Mparaiso,項目名稱:apipress,代碼行數:7,代碼來源:builder_test.go

示例4: TestParser

func TestParser(t *testing.T) {
	testLogger := logger.NewTestLogger(t)

	for _, fixture := range []struct {
		String      string
		Length      int
		Definitions []*tag.Definition
	}{
		{`field:foo;complex_field(name:param,name2:param2,name_3:3);field:1;last_field`,
			4,
			[]*tag.Definition{
				{Name: "field", Value: "foo"},
				{Name: "complex_field", Parameters: []tag.Parameter{{Key: "name", Value: "param"}, {Key: "name2", Value: "param2"}, {Key: "name_3", Value: "3"}}},
				{Name: "field", Value: "1"},
				{Name: "last_field"},
			},
		},
	} {
		parser := tag.NewParser(strings.NewReader(fixture.String))
		parser.SetLogger(testLogger)
		definitions, err := parser.Parse()
		test.Fatal(t, err, nil)
		test.Fatal(t, len(definitions), fixture.Length)
		test.Fatal(t, reflect.DeepEqual(definitions, fixture.Definitions), true)
	}

}
開發者ID:Mparaiso,項目名稱:apipress,代碼行數:27,代碼來源:parser_test.go

示例5: TestMongo

func TestMongo(t *testing.T) {

	type Test struct {
		ID bson.ObjectId `bson:"_id,omitempty"`
		Name,
		Description string
	}

	session, err := mgo.Dial(os.Getenv("MONGODB_TEST_SERVER"))
	test.Fatal(t, err, nil)
	defer session.Close()
	defer session.DB(os.Getenv("MONGODB_TEST_DB")).C("mongo_tests").DropCollection()

	// Optional. Switch the session to a monotonic behavior.
	session.SetMode(mgo.Monotonic, true)
	collection := session.DB(os.Getenv("MONGODB_TEST_DB")).C("mongo_tests")
	test1 := &Test{Name: "Initial", Description: "A simple test"}
	err = collection.Insert(test1)
	test.Fatal(t, err, nil)
	result := new(Test)
	err = collection.Find(bson.M{"name": test1.Name}).One(result)
	test.Error(t, err, nil)
	test.Error(t, result.Description, test1.Description)
	result1 := new(Test)
	err = collection.FindId(result.ID).One(result1)
	test.Error(t, err, nil)
	test.Error(t, result1.ID, result.ID)
}
開發者ID:Mparaiso,項目名稱:apipress,代碼行數:28,代碼來源:mongo_test.go

示例6: TestConnectionPrepare

func TestConnectionPrepare(t *testing.T) {
	connection := GetConnection(t)
	defer connection.Close()
	result, err := connection.Prepare("SELECT * from users").Exec()
	test.Fatal(t, err, nil)
	test.Fatal(t, result != nil, true)
}
開發者ID:Mparaiso,項目名稱:apipress,代碼行數:7,代碼來源:connection_test.go

示例7: TestConnectionArray

func TestConnectionArray(t *testing.T) {
	connection := GetConnection(t)
	LoadFixtures(connection)
	var users []*AppUser
	err := connection.Query("SELECT * FROM users WHERE name IN (?,?)", []interface{}{"John Doe", "Jane Doe"}...).GetResults(&users)
	test.Fatal(t, err, nil)
	test.Fatal(t, len(users), 2)
}
開發者ID:Mparaiso,項目名稱:apipress,代碼行數:8,代碼來源:connection_test.go

示例8: SubTestDocumentManager_FindOne

func SubTestDocumentManager_FindOne(dm mongo.DocumentManager, t *testing.T) bson.ObjectId {
	user := new(User)
	err := dm.FindOne(bson.M{"Name": "John"}, user)
	test.Fatal(t, err, nil)
	test.Fatal(t, user.Role != nil, true)
	test.Fatal(t, user.Role.Title, "Editor")
	return user.ID
}
開發者ID:Mparaiso,項目名稱:apipress,代碼行數:8,代碼來源:mongo_test.go

示例9: SubTestDocumentManager_FindAll

func SubTestDocumentManager_FindAll(dm mongo.DocumentManager, t *testing.T) {
	users := []*User{}
	err := dm.FindAll(&users)
	test.Fatal(t, err, nil)
	test.Fatal(t, len(users), 1)
	test.Fatal(t, len(users[0].Posts), 1)
	test.Fatal(t, users[0].Posts[0].Title, "First Post Title")
	test.Fatal(t, users[0].Role != nil, true)
}
開發者ID:Mparaiso,項目名稱:apipress,代碼行數:9,代碼來源:mongo_test.go

示例10: TestUpdate

func TestUpdate(t *testing.T) {
	connection := NewTestConnection(t)
	qb := db.NewQueryBuilder(connection)
	qb.Update("users", "u").
		Set("u.foo", "?").
		Set("u.bar", "?")
	test.Fatal(t, qb.GetType(), db.Update)
	test.Fatal(t, qb.String(), "UPDATE users u SET u.foo = ?, u.bar = ?")
}
開發者ID:Mparaiso,項目名稱:apipress,代碼行數:9,代碼來源:builder_test.go

示例11: TestGetState

func TestGetState(t *testing.T) {
	connection := NewTestConnection(t)
	qb := db.NewQueryBuilder(connection)
	test.Fatal(t, qb.GetState(), db.Clean)
	qb.Select("u.*").From("users", "u")
	test.Fatal(t, qb.GetState(), db.Dirty)
	qb.String()
	test.Fatal(t, qb.GetState(), db.Clean)
}
開發者ID:Mparaiso,項目名稱:apipress,代碼行數:9,代碼來源:builder_test.go

示例12: TestSQLTagBuilder

func TestSQLTagBuilder(t *testing.T) {
	tag := "column:nick_name"
	sqlTag := db.SQLStructTagBuilder{logger.NewTestLogger(t)}.BuildFromString(tag)
	test.Fatal(t, sqlTag.ColumnName, "nick_name")
	test.Fatal(t, sqlTag.PersistZeroValue, false)
	tag = "column:email_address,persistzerovalue"
	sqlTag = db.SQLStructTagBuilder{logger.NewTestLogger(t)}.BuildFromString(tag)
	test.Fatal(t, sqlTag.ColumnName, "email_address")
	test.Fatal(t, sqlTag.PersistZeroValue, true)
}
開發者ID:Mparaiso,項目名稱:apipress,代碼行數:10,代碼來源:row_struct_mapper_test.go

示例13: TestInsertValuesSetValue

func TestInsertValuesSetValue(t *testing.T) {
	connection := NewTestConnection(t)

	qb := db.NewQueryBuilder(connection)
	qb.Insert("users").
		SetValue("foo", "?").
		SetValue("bar", "?")
	test.Fatal(t, db.Insert, qb.GetType())
	test.Fatal(t, "INSERT INTO users (foo, bar) VALUES(?, ?)", qb.String())
}
開發者ID:Mparaiso,項目名稱:apipress,代碼行數:10,代碼來源:builder_test.go

示例14: TestDocumentManager_CreateQuery_Select

func TestDocumentManager_CreateQuery_Select(t *testing.T) {
	t.Log("QueryBuilder.Select should also affect which relations are resolved")
	dm, done := getDocumentManager(t)
	defer done()
	err := dm.RegisterMany(map[string]interface{}{
		"Client":   new(Client),
		"Employee": new(Employee),
		"Project":  new(Project),
	})
	test.Fatal(t, err, nil)
	client := &Client{Name: "Example"}
	employee := &Employee{Name: "John Doe"}
	project := &Project{Title: "Project", Employee: employee}
	client.Projects = append(client.Projects, project)
	dm.Persist(client)
	dm.Persist(employee)
	dm.Persist(project)
	err = dm.Flush()
	test.Fatal(t, err, nil)
	projects := []*Project{}
	err = dm.CreateQuery().Select(bson.M{"Client": 1}).All(&projects)
	test.Fatal(t, err, nil)
	test.Fatal(t, projects[0].Employee == nil, true)
	test.Fatal(t, projects[0].Client.Name, "Example")
	client = new(Client)
	err = dm.CreateQuery().Select(bson.M{"Name": 1}).One(client)
	test.Fatal(t, err, nil)
	test.Fatal(t, len(client.Projects), 0)
	err = dm.FindID(client.ID, client)
	test.Fatal(t, err, nil)
	test.Fatal(t, len(client.Projects), 1)
}
開發者ID:Mparaiso,項目名稱:apipress,代碼行數:32,代碼來源:mongo_test.go

示例15: TestInjector_Resolve_CircularDependency

func TestInjector_Resolve_CircularDependency(t *testing.T) {
	container := injector.NewInjector()
	container.SetLogger(test.NewTestLogger(t))
	err := container.RegisterFactory(func(i int) (int, error) {
		return i, nil
	})
	test.Fatal(t, err, nil)
	var i int
	err = container.Resolve(&i)
	test.Fatal(t, err, injector.ErrorCircularDependency)
}
開發者ID:Mparaiso,項目名稱:apipress,代碼行數:11,代碼來源:injector_test.go


注:本文中的github.com/Mparaiso/go-tiger/test.Fatal函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。