• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang boil.Begin函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/vattle/sqlboiler/boil.Begin函数的典型用法代码示例。如果您正苦于以下问题:Golang Begin函数的具体用法?Golang Begin怎么用?Golang Begin使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了Begin函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: testStockpropPubsSliceDeleteAll

func testStockpropPubsSliceDeleteAll(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); err != nil {
		t.Error(err)
	}

	slice := StockpropPubSlice{stockpropPub}

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

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

	if count != 0 {
		t.Error("want zero records, got:", count)
	}
}
开发者ID:dictyBase,项目名称:Modware,代码行数:31,代码来源:stockprop_pub_test.go


示例17: testThumbnailsInsertWhitelist

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

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

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

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

	if count != 1 {
		t.Error("want one record, got:", count)
	}
}
开发者ID:zqzca,项目名称:back,代码行数:25,代码来源:thumbnails_test.go


示例18: testOrganismDbxrefsFind

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

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

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

	organismDbxrefFound, err := FindOrganismDbxref(tx, organismDbxref.OrganismDbxrefID)
	if err != nil {
		t.Error(err)
	}

	if organismDbxrefFound == nil {
		t.Error("want a record, got nil")
	}
}
开发者ID:dictyBase,项目名称:Modware,代码行数:25,代码来源:organism_dbxref_test.go


示例19: testThumbnailsSliceDeleteAll

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

	seed := randomize.NewSeed()
	var err error
	thumbnail := &Thumbnail{}
	if err = randomize.Struct(seed, thumbnail, thumbnailDBTypes, true); 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 := ThumbnailSlice{thumbnail}

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

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

	if count != 0 {
		t.Error("want zero records, got:", count)
	}
}
开发者ID:zqzca,项目名称:back,代码行数:31,代码来源:thumbnails_test.go


示例20: testOrganismDbxrefsCount

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

	var err error
	seed := randomize.NewSeed()
	organismDbxrefOne := &OrganismDbxref{}
	organismDbxrefTwo := &OrganismDbxref{}
	if err = randomize.Struct(seed, organismDbxrefOne, organismDbxrefDBTypes, false, organismDbxrefColumnsWithDefault...); err != nil {
		t.Errorf("Unable to randomize OrganismDbxref struct: %s", err)
	}
	if err = randomize.Struct(seed, organismDbxrefTwo, organismDbxrefDBTypes, false, organismDbxrefColumnsWithDefault...); err != nil {
		t.Errorf("Unable to randomize OrganismDbxref struct: %s", err)
	}

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

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

	if count != 2 {
		t.Error("want 2 records, got:", count)
	}
}
开发者ID:dictyBase,项目名称:Modware,代码行数:32,代码来源:organism_dbxref_test.go



注:本文中的github.com/vattle/sqlboiler/boil.Begin函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang boil.GetDB函数代码示例发布时间:2022-05-28
下一篇:
Golang models.User类代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap