Golang Begin示例

说明

golang begin示例是从最受好评的开源项目中提取的实现代码,你可以参考下面示例的使用方式。

编程语言: Golang

命名空间/包名称: github.com/vattle/sqlboiler/boil

示例#1
文件: users_test.go 项目: zqzca/back

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")
	}
}

示例#2
文件: pubauthor_test.go 项目: dictyBase/Modware

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)
	}
}

示例#3
文件: pubauthor_test.go 项目: dictyBase/Modware

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))
	}
}

示例#4
文件: cvtermpath_test.go 项目: dictyBase/Modware

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)
	}
}

示例#5
文件: cvtermpath_test.go 项目: dictyBase/Modware

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))
	}
}

示例#6
文件: thumbnails_test.go 项目: zqzca/back

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))
	}
}

示例#7
文件: cvtermpath_test.go 项目: dictyBase/Modware

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")
	}
}

示例#8
文件: stockprop_pub_test.go 项目: dictyBase/Modware

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)
	}
}

示例#9
文件: stockprop_pub_test.go 项目: dictyBase/Modware

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))
	}
}

示例#10
文件: stockprop_pub_test.go 项目: dictyBase/Modware

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")
	}
}

示例#11
文件: stockprop_pub_test.go 项目: dictyBase/Modware

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)
	}
}

示例#12
文件: users_test.go 项目: zqzca/back

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)
	}
}

示例#13
文件: users_test.go 项目: zqzca/back

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)
	}
}

示例#14
文件: users_test.go 项目: zqzca/back

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))
	}
}

示例#15
文件: thumbnails_test.go 项目: zqzca/back

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)
	}
}

示例#16
文件: stockprop_pub_test.go 项目: dictyBase/Modware

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)
	}
}

示例#17
文件: thumbnails_test.go 项目: zqzca/back

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)
	}
}

示例#18
文件: organism_dbxref_test.go 项目: dictyBase/Modware

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")
	}
}

示例#19
文件: thumbnails_test.go 项目: zqzca/back

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)
	}
}

示例#20
文件: organism_dbxref_test.go 项目: dictyBase/Modware

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)
	}
}

示例#21
文件: cvtermpath_test.go 项目: dictyBase/Modware

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

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

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

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

	if count != 2 {
		t.Error("want 2 records, got:", count)
	}
}

示例#22
文件: organism_dbxref_test.go 项目: dictyBase/Modware

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

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

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

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

	if count != 1 {
		t.Error("want one record, got:", count)
	}
}

示例#23
文件: cvtermpath_test.go 项目: dictyBase/Modware

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

	slice := CvtermpathSlice{cvtermpath}

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

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

	if count != 0 {
		t.Error("want zero records, got:", count)
	}
}

示例#24
文件: organism_dbxref_test.go 项目: dictyBase/Modware

func testOrganismDbxrefsSelect(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)
	}

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

	if len(slice) != 1 {
		t.Error("want one record, got:", len(slice))
	}
}

示例#25
文件: pubauthor_test.go 项目: dictyBase/Modware

func testPubauthorsFind(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)
	}

	pubauthorFound, err := FindPubauthor(tx, pubauthor.PubauthorID)
	if err != nil {
		t.Error(err)
	}

	if pubauthorFound == nil {
		t.Error("want a record, got nil")
	}
}

示例#26
文件: organism_dbxref_test.go 项目: dictyBase/Modware

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

	seed := randomize.NewSeed()
	var err error
	organismDbxref := &OrganismDbxref{}
	if err = randomize.Struct(seed, organismDbxref, organismDbxrefDBTypes, true); 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)
	}

	slice := OrganismDbxrefSlice{organismDbxref}

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

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

	if count != 0 {
		t.Error("want zero records, got:", count)
	}
}

示例#27
文件: pubauthor_test.go 项目: dictyBase/Modware

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

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

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

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

	if count != 1 {
		t.Error("want one record, got:", count)
	}
}

示例#28
文件: thumbnails_test.go 项目: zqzca/back

func testThumbnailsFind(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)
	}

	thumbnailFound, err := FindThumbnail(tx, thumbnail.ID)
	if err != nil {
		t.Error(err)
	}

	if thumbnailFound == nil {
		t.Error("want a record, got nil")
	}
}

示例#29
文件: pubauthor_test.go 项目: dictyBase/Modware

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

	seed := randomize.NewSeed()
	var err error
	pubauthor := &Pubauthor{}
	if err = randomize.Struct(seed, pubauthor, pubauthorDBTypes, true); 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 := PubauthorSlice{pubauthor}

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

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

	if count != 0 {
		t.Error("want zero records, got:", count)
	}
}

示例#30
文件: feature_phenotype_test.go 项目: dictyBase/Modware

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

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

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

	slice := FeaturePhenotypeSlice{featurePhenotype}

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

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

	if count != 0 {
		t.Error("want zero records, got:", count)
	}
}

展开阅读全文