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


Golang boil.Begin函數代碼示例

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


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

示例1: testUsersFind

func testUsersFind(t *testing.T) {
	t.Parallel()

	seed := randomize.NewSeed()
	var err error
	user := &User{}
	if err = randomize.Struct(seed, user, userDBTypes, true, userColumnsWithDefault...); err != nil {
		t.Errorf("Unable to randomize User struct: %s", err)
	}

	tx := MustTx(boil.Begin())
	defer tx.Rollback()
	if err = user.Insert(tx); err != nil {
		t.Error(err)
	}

	userFound, err := FindUser(tx, user.ID)
	if err != nil {
		t.Error(err)
	}

	if userFound == nil {
		t.Error("want a record, got nil")
	}
}
開發者ID:zqzca,項目名稱:back,代碼行數:25,代碼來源:users_test.go

示例2: testPubauthorsCount

func testPubauthorsCount(t *testing.T) {
	t.Parallel()

	var err error
	seed := randomize.NewSeed()
	pubauthorOne := &Pubauthor{}
	pubauthorTwo := &Pubauthor{}
	if err = randomize.Struct(seed, pubauthorOne, pubauthorDBTypes, false, pubauthorColumnsWithDefault...); err != nil {
		t.Errorf("Unable to randomize Pubauthor struct: %s", err)
	}
	if err = randomize.Struct(seed, pubauthorTwo, pubauthorDBTypes, false, pubauthorColumnsWithDefault...); err != nil {
		t.Errorf("Unable to randomize Pubauthor struct: %s", err)
	}

	tx := MustTx(boil.Begin())
	defer tx.Rollback()
	if err = pubauthorOne.Insert(tx); err != nil {
		t.Error(err)
	}
	if err = pubauthorTwo.Insert(tx); err != nil {
		t.Error(err)
	}

	count, err := Pubauthors(tx).Count()
	if err != nil {
		t.Error(err)
	}

	if count != 2 {
		t.Error("want 2 records, got:", count)
	}
}
開發者ID:dictyBase,項目名稱:Modware,代碼行數:32,代碼來源:pubauthor_test.go

示例3: testPubauthorsSelect

func testPubauthorsSelect(t *testing.T) {
	t.Parallel()

	seed := randomize.NewSeed()
	var err error
	pubauthor := &Pubauthor{}
	if err = randomize.Struct(seed, pubauthor, pubauthorDBTypes, true, pubauthorColumnsWithDefault...); err != nil {
		t.Errorf("Unable to randomize Pubauthor struct: %s", err)
	}

	tx := MustTx(boil.Begin())
	defer tx.Rollback()
	if err = pubauthor.Insert(tx); err != nil {
		t.Error(err)
	}

	slice, err := Pubauthors(tx).All()
	if err != nil {
		t.Error(err)
	}

	if len(slice) != 1 {
		t.Error("want one record, got:", len(slice))
	}
}
開發者ID:dictyBase,項目名稱:Modware,代碼行數:25,代碼來源:pubauthor_test.go

示例4: testCvtermpathsInsertWhitelist

func testCvtermpathsInsertWhitelist(t *testing.T) {
	t.Parallel()

	seed := randomize.NewSeed()
	var err error
	cvtermpath := &Cvtermpath{}
	if err = randomize.Struct(seed, cvtermpath, cvtermpathDBTypes, true); err != nil {
		t.Errorf("Unable to randomize Cvtermpath struct: %s", err)
	}

	tx := MustTx(boil.Begin())
	defer tx.Rollback()
	if err = cvtermpath.Insert(tx, cvtermpathColumns...); err != nil {
		t.Error(err)
	}

	count, err := Cvtermpaths(tx).Count()
	if err != nil {
		t.Error(err)
	}

	if count != 1 {
		t.Error("want one record, got:", count)
	}
}
開發者ID:dictyBase,項目名稱:Modware,代碼行數:25,代碼來源:cvtermpath_test.go

示例5: testCvtermpathsSelect

func testCvtermpathsSelect(t *testing.T) {
	t.Parallel()

	seed := randomize.NewSeed()
	var err error
	cvtermpath := &Cvtermpath{}
	if err = randomize.Struct(seed, cvtermpath, cvtermpathDBTypes, true, cvtermpathColumnsWithDefault...); err != nil {
		t.Errorf("Unable to randomize Cvtermpath struct: %s", err)
	}

	tx := MustTx(boil.Begin())
	defer tx.Rollback()
	if err = cvtermpath.Insert(tx); err != nil {
		t.Error(err)
	}

	slice, err := Cvtermpaths(tx).All()
	if err != nil {
		t.Error(err)
	}

	if len(slice) != 1 {
		t.Error("want one record, got:", len(slice))
	}
}
開發者ID:dictyBase,項目名稱:Modware,代碼行數:25,代碼來源:cvtermpath_test.go

示例6: testThumbnailsSelect

func testThumbnailsSelect(t *testing.T) {
	t.Parallel()

	seed := randomize.NewSeed()
	var err error
	thumbnail := &Thumbnail{}
	if err = randomize.Struct(seed, thumbnail, thumbnailDBTypes, true, thumbnailColumnsWithDefault...); err != nil {
		t.Errorf("Unable to randomize Thumbnail struct: %s", err)
	}

	tx := MustTx(boil.Begin())
	defer tx.Rollback()
	if err = thumbnail.Insert(tx); err != nil {
		t.Error(err)
	}

	slice, err := Thumbnails(tx).All()
	if err != nil {
		t.Error(err)
	}

	if len(slice) != 1 {
		t.Error("want one record, got:", len(slice))
	}
}
開發者ID:zqzca,項目名稱:back,代碼行數:25,代碼來源:thumbnails_test.go

示例7: testCvtermpathsFind

func testCvtermpathsFind(t *testing.T) {
	t.Parallel()

	seed := randomize.NewSeed()
	var err error
	cvtermpath := &Cvtermpath{}
	if err = randomize.Struct(seed, cvtermpath, cvtermpathDBTypes, true, cvtermpathColumnsWithDefault...); err != nil {
		t.Errorf("Unable to randomize Cvtermpath struct: %s", err)
	}

	tx := MustTx(boil.Begin())
	defer tx.Rollback()
	if err = cvtermpath.Insert(tx); err != nil {
		t.Error(err)
	}

	cvtermpathFound, err := FindCvtermpath(tx, cvtermpath.CvtermpathID)
	if err != nil {
		t.Error(err)
	}

	if cvtermpathFound == nil {
		t.Error("want a record, got nil")
	}
}
開發者ID:dictyBase,項目名稱:Modware,代碼行數:25,代碼來源:cvtermpath_test.go

示例8: testStockpropPubsInsertWhitelist

func testStockpropPubsInsertWhitelist(t *testing.T) {
	t.Parallel()

	seed := randomize.NewSeed()
	var err error
	stockpropPub := &StockpropPub{}
	if err = randomize.Struct(seed, stockpropPub, stockpropPubDBTypes, true); err != nil {
		t.Errorf("Unable to randomize StockpropPub struct: %s", err)
	}

	tx := MustTx(boil.Begin())
	defer tx.Rollback()
	if err = stockpropPub.Insert(tx, stockpropPubColumns...); err != nil {
		t.Error(err)
	}

	count, err := StockpropPubs(tx).Count()
	if err != nil {
		t.Error(err)
	}

	if count != 1 {
		t.Error("want one record, got:", count)
	}
}
開發者ID:dictyBase,項目名稱:Modware,代碼行數:25,代碼來源:stockprop_pub_test.go

示例9: testStockpropPubsSelect

func testStockpropPubsSelect(t *testing.T) {
	t.Parallel()

	seed := randomize.NewSeed()
	var err error
	stockpropPub := &StockpropPub{}
	if err = randomize.Struct(seed, stockpropPub, stockpropPubDBTypes, true, stockpropPubColumnsWithDefault...); err != nil {
		t.Errorf("Unable to randomize StockpropPub struct: %s", err)
	}

	tx := MustTx(boil.Begin())
	defer tx.Rollback()
	if err = stockpropPub.Insert(tx); err != nil {
		t.Error(err)
	}

	slice, err := StockpropPubs(tx).All()
	if err != nil {
		t.Error(err)
	}

	if len(slice) != 1 {
		t.Error("want one record, got:", len(slice))
	}
}
開發者ID:dictyBase,項目名稱:Modware,代碼行數:25,代碼來源:stockprop_pub_test.go

示例10: testStockpropPubsFind

func testStockpropPubsFind(t *testing.T) {
	t.Parallel()

	seed := randomize.NewSeed()
	var err error
	stockpropPub := &StockpropPub{}
	if err = randomize.Struct(seed, stockpropPub, stockpropPubDBTypes, true, stockpropPubColumnsWithDefault...); err != nil {
		t.Errorf("Unable to randomize StockpropPub struct: %s", err)
	}

	tx := MustTx(boil.Begin())
	defer tx.Rollback()
	if err = stockpropPub.Insert(tx); err != nil {
		t.Error(err)
	}

	stockpropPubFound, err := FindStockpropPub(tx, stockpropPub.StockpropPubID)
	if err != nil {
		t.Error(err)
	}

	if stockpropPubFound == nil {
		t.Error("want a record, got nil")
	}
}
開發者ID:dictyBase,項目名稱:Modware,代碼行數:25,代碼來源:stockprop_pub_test.go

示例11: testStockpropPubsCount

func testStockpropPubsCount(t *testing.T) {
	t.Parallel()

	var err error
	seed := randomize.NewSeed()
	stockpropPubOne := &StockpropPub{}
	stockpropPubTwo := &StockpropPub{}
	if err = randomize.Struct(seed, stockpropPubOne, stockpropPubDBTypes, false, stockpropPubColumnsWithDefault...); err != nil {
		t.Errorf("Unable to randomize StockpropPub struct: %s", err)
	}
	if err = randomize.Struct(seed, stockpropPubTwo, stockpropPubDBTypes, false, stockpropPubColumnsWithDefault...); err != nil {
		t.Errorf("Unable to randomize StockpropPub struct: %s", err)
	}

	tx := MustTx(boil.Begin())
	defer tx.Rollback()
	if err = stockpropPubOne.Insert(tx); err != nil {
		t.Error(err)
	}
	if err = stockpropPubTwo.Insert(tx); err != nil {
		t.Error(err)
	}

	count, err := StockpropPubs(tx).Count()
	if err != nil {
		t.Error(err)
	}

	if count != 2 {
		t.Error("want 2 records, got:", count)
	}
}
開發者ID:dictyBase,項目名稱:Modware,代碼行數:32,代碼來源:stockprop_pub_test.go

示例12: testUsersQueryDeleteAll

func testUsersQueryDeleteAll(t *testing.T) {
	t.Parallel()

	seed := randomize.NewSeed()
	var err error
	user := &User{}
	if err = randomize.Struct(seed, user, userDBTypes, true); err != nil {
		t.Errorf("Unable to randomize User struct: %s", err)
	}

	tx := MustTx(boil.Begin())
	defer tx.Rollback()
	if err = user.Insert(tx); err != nil {
		t.Error(err)
	}

	if err = Users(tx).DeleteAll(); err != nil {
		t.Error(err)
	}

	count, err := Users(tx).Count()
	if err != nil {
		t.Error(err)
	}

	if count != 0 {
		t.Error("want zero records, got:", count)
	}
}
開發者ID:zqzca,項目名稱:back,代碼行數:29,代碼來源:users_test.go

示例13: testUsersInsert

func testUsersInsert(t *testing.T) {
	t.Parallel()

	seed := randomize.NewSeed()
	var err error
	user := &User{}
	if err = randomize.Struct(seed, user, userDBTypes, true, userColumnsWithDefault...); err != nil {
		t.Errorf("Unable to randomize User struct: %s", err)
	}

	tx := MustTx(boil.Begin())
	defer tx.Rollback()
	if err = user.Insert(tx); err != nil {
		t.Error(err)
	}

	count, err := Users(tx).Count()
	if err != nil {
		t.Error(err)
	}

	if count != 1 {
		t.Error("want one record, got:", count)
	}
}
開發者ID:zqzca,項目名稱:back,代碼行數:25,代碼來源:users_test.go

示例14: testUsersAll

func testUsersAll(t *testing.T) {
	t.Parallel()

	seed := randomize.NewSeed()
	var err error
	userOne := &User{}
	userTwo := &User{}
	if err = randomize.Struct(seed, userOne, userDBTypes, false, userColumnsWithDefault...); err != nil {
		t.Errorf("Unable to randomize User struct: %s", err)
	}
	if err = randomize.Struct(seed, userTwo, userDBTypes, false, userColumnsWithDefault...); err != nil {
		t.Errorf("Unable to randomize User struct: %s", err)
	}

	tx := MustTx(boil.Begin())
	defer tx.Rollback()
	if err = userOne.Insert(tx); err != nil {
		t.Error(err)
	}
	if err = userTwo.Insert(tx); err != nil {
		t.Error(err)
	}

	slice, err := Users(tx).All()
	if err != nil {
		t.Error(err)
	}

	if len(slice) != 2 {
		t.Error("want 2 records, got:", len(slice))
	}
}
開發者ID:zqzca,項目名稱:back,代碼行數:32,代碼來源:users_test.go

示例15: testThumbnailsCount

func testThumbnailsCount(t *testing.T) {
	t.Parallel()

	var err error
	seed := randomize.NewSeed()
	thumbnailOne := &Thumbnail{}
	thumbnailTwo := &Thumbnail{}
	if err = randomize.Struct(seed, thumbnailOne, thumbnailDBTypes, false, thumbnailColumnsWithDefault...); err != nil {
		t.Errorf("Unable to randomize Thumbnail struct: %s", err)
	}
	if err = randomize.Struct(seed, thumbnailTwo, thumbnailDBTypes, false, thumbnailColumnsWithDefault...); err != nil {
		t.Errorf("Unable to randomize Thumbnail struct: %s", err)
	}

	tx := MustTx(boil.Begin())
	defer tx.Rollback()
	if err = thumbnailOne.Insert(tx); err != nil {
		t.Error(err)
	}
	if err = thumbnailTwo.Insert(tx); err != nil {
		t.Error(err)
	}

	count, err := Thumbnails(tx).Count()
	if err != nil {
		t.Error(err)
	}

	if count != 2 {
		t.Error("want 2 records, got:", count)
	}
}
開發者ID:zqzca,項目名稱:back,代碼行數:32,代碼來源:thumbnails_test.go


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