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

Golang randomize.Struct函数代码示例

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

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



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

示例1: testUserRelationshipsCount

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

	var err error
	seed := randomize.NewSeed()
	userRelationshipOne := &UserRelationship{}
	userRelationshipTwo := &UserRelationship{}
	if err = randomize.Struct(seed, userRelationshipOne, userRelationshipDBTypes, false, userRelationshipColumnsWithDefault...); err != nil {
		t.Errorf("Unable to randomize UserRelationship struct: %s", err)
	}
	if err = randomize.Struct(seed, userRelationshipTwo, userRelationshipDBTypes, false, userRelationshipColumnsWithDefault...); err != nil {
		t.Errorf("Unable to randomize UserRelationship struct: %s", err)
	}

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

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

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


示例2: 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


示例3: 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


示例4: testFeaturePhenotypesCount

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

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

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

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

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


示例5: 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


示例6: testPhenotypeCvtermsAll

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

	seed := randomize.NewSeed()
	var err error
	phenotypeCvtermOne := &PhenotypeCvterm{}
	phenotypeCvtermTwo := &PhenotypeCvterm{}
	if err = randomize.Struct(seed, phenotypeCvtermOne, phenotypeCvtermDBTypes, false, phenotypeCvtermColumnsWithDefault...); err != nil {
		t.Errorf("Unable to randomize PhenotypeCvterm struct: %s", err)
	}
	if err = randomize.Struct(seed, phenotypeCvtermTwo, phenotypeCvtermDBTypes, false, phenotypeCvtermColumnsWithDefault...); err != nil {
		t.Errorf("Unable to randomize PhenotypeCvterm struct: %s", err)
	}

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

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

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


示例7: testEnvironmentCvtermsCount

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

	var err error
	seed := randomize.NewSeed()
	environmentCvtermOne := &EnvironmentCvterm{}
	environmentCvtermTwo := &EnvironmentCvterm{}
	if err = randomize.Struct(seed, environmentCvtermOne, environmentCvtermDBTypes, false, environmentCvtermColumnsWithDefault...); err != nil {
		t.Errorf("Unable to randomize EnvironmentCvterm struct: %s", err)
	}
	if err = randomize.Struct(seed, environmentCvtermTwo, environmentCvtermDBTypes, false, environmentCvtermColumnsWithDefault...); err != nil {
		t.Errorf("Unable to randomize EnvironmentCvterm struct: %s", err)
	}

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

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

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


示例8: testAuthRoleOneToOneSetOpAuthRolePermissionUsingAuthRolePermission

func testAuthRoleOneToOneSetOpAuthRolePermissionUsingAuthRolePermission(t *testing.T) {
	var err error

	tx := MustTx(boil.Begin())
	defer tx.Rollback()

	var a AuthRole
	var b, c AuthRolePermission

	seed := randomize.NewSeed()
	if err = randomize.Struct(seed, &a, authRoleDBTypes, false, strmangle.SetComplement(authRolePrimaryKeyColumns, authRoleColumnsWithoutDefault)...); err != nil {
		t.Fatal(err)
	}
	if err = randomize.Struct(seed, &b, authRolePermissionDBTypes, false, strmangle.SetComplement(authRolePermissionPrimaryKeyColumns, authRolePermissionColumnsWithoutDefault)...); err != nil {
		t.Fatal(err)
	}
	if err = randomize.Struct(seed, &c, authRolePermissionDBTypes, false, strmangle.SetComplement(authRolePermissionPrimaryKeyColumns, authRolePermissionColumnsWithoutDefault)...); err != nil {
		t.Fatal(err)
	}

	if err := a.Insert(tx); err != nil {
		t.Fatal(err)
	}
	if err = b.Insert(tx); err != nil {
		t.Fatal(err)
	}

	for i, x := range []*AuthRolePermission{&b, &c} {
		err = a.SetAuthRolePermission(tx, i != 0, x)
		if err != nil {
			t.Fatal(err)
		}

		if a.R.AuthRolePermission != x {
			t.Error("relationship struct not set to correct value")
		}
		if x.R.AuthRole != &a {
			t.Error("failed to append to foreign relationship struct")
		}

		if a.AuthRoleID != x.AuthRoleID {
			t.Error("foreign key was wrong value", a.AuthRoleID)
		}

		zero := reflect.Zero(reflect.TypeOf(x.AuthRoleID))
		reflect.Indirect(reflect.ValueOf(&x.AuthRoleID)).Set(zero)

		if err = x.Reload(tx); err != nil {
			t.Fatal("failed to reload", err)
		}

		if a.AuthRoleID != x.AuthRoleID {
			t.Error("foreign key was wrong value", a.AuthRoleID, x.AuthRoleID)
		}

		if err = x.Delete(tx); err != nil {
			t.Fatal("failed to delete x", err)
		}
	}
}
开发者ID:dictyBase,项目名称:Modware,代码行数:60,代码来源:auth_role_test.go


示例9: testEnvironmentsAll

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

	seed := randomize.NewSeed()
	var err error
	environmentOne := &Environment{}
	environmentTwo := &Environment{}
	if err = randomize.Struct(seed, environmentOne, environmentDBTypes, false, environmentColumnsWithDefault...); err != nil {
		t.Errorf("Unable to randomize Environment struct: %s", err)
	}
	if err = randomize.Struct(seed, environmentTwo, environmentDBTypes, false, environmentColumnsWithDefault...); err != nil {
		t.Errorf("Unable to randomize Environment struct: %s", err)
	}

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

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

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


示例10: testDBSCount

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

	var err error
	seed := randomize.NewSeed()
	dbOne := &DB{}
	dbTwo := &DB{}
	if err = randomize.Struct(seed, dbOne, dbDBTypes, false, dbColumnsWithDefault...); err != nil {
		t.Errorf("Unable to randomize DB struct: %s", err)
	}
	if err = randomize.Struct(seed, dbTwo, dbDBTypes, false, dbColumnsWithDefault...); err != nil {
		t.Errorf("Unable to randomize DB struct: %s", err)
	}

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

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

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


示例11: testAuthPermissionsCount

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

	var err error
	seed := randomize.NewSeed()
	authPermissionOne := &AuthPermission{}
	authPermissionTwo := &AuthPermission{}
	if err = randomize.Struct(seed, authPermissionOne, authPermissionDBTypes, false, authPermissionColumnsWithDefault...); err != nil {
		t.Errorf("Unable to randomize AuthPermission struct: %s", err)
	}
	if err = randomize.Struct(seed, authPermissionTwo, authPermissionDBTypes, false, authPermissionColumnsWithDefault...); err != nil {
		t.Errorf("Unable to randomize AuthPermission struct: %s", err)
	}

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

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

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


示例12: testAnalysesAll

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

	seed := randomize.NewSeed()
	var err error
	analysiOne := &Analysi{}
	analysiTwo := &Analysi{}
	if err = randomize.Struct(seed, analysiOne, analysiDBTypes, false, analysiColumnsWithDefault...); err != nil {
		t.Errorf("Unable to randomize Analysi struct: %s", err)
	}
	if err = randomize.Struct(seed, analysiTwo, analysiDBTypes, false, analysiColumnsWithDefault...); err != nil {
		t.Errorf("Unable to randomize Analysi struct: %s", err)
	}

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

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

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


示例13: testTableinfosAll

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

	seed := randomize.NewSeed()
	var err error
	tableinfoOne := &Tableinfo{}
	tableinfoTwo := &Tableinfo{}
	if err = randomize.Struct(seed, tableinfoOne, tableinfoDBTypes, false, tableinfoColumnsWithDefault...); err != nil {
		t.Errorf("Unable to randomize Tableinfo struct: %s", err)
	}
	if err = randomize.Struct(seed, tableinfoTwo, tableinfoDBTypes, false, tableinfoColumnsWithDefault...); err != nil {
		t.Errorf("Unable to randomize Tableinfo struct: %s", err)
	}

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

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

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


示例14: testJbrowseOrganismsAll

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

	seed := randomize.NewSeed()
	var err error
	jbrowseOrganismOne := &JbrowseOrganism{}
	jbrowseOrganismTwo := &JbrowseOrganism{}
	if err = randomize.Struct(seed, jbrowseOrganismOne, jbrowseOrganismDBTypes, false, jbrowseOrganismColumnsWithDefault...); err != nil {
		t.Errorf("Unable to randomize JbrowseOrganism struct: %s", err)
	}
	if err = randomize.Struct(seed, jbrowseOrganismTwo, jbrowseOrganismDBTypes, false, jbrowseOrganismColumnsWithDefault...); err != nil {
		t.Errorf("Unable to randomize JbrowseOrganism struct: %s", err)
	}

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

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

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


示例15: testCvtermDbxrefsAll

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

	seed := randomize.NewSeed()
	var err error
	cvtermDbxrefOne := &CvtermDbxref{}
	cvtermDbxrefTwo := &CvtermDbxref{}
	if err = randomize.Struct(seed, cvtermDbxrefOne, cvtermDbxrefDBTypes, false, cvtermDbxrefColumnsWithDefault...); err != nil {
		t.Errorf("Unable to randomize CvtermDbxref struct: %s", err)
	}
	if err = randomize.Struct(seed, cvtermDbxrefTwo, cvtermDbxrefDBTypes, false, cvtermDbxrefColumnsWithDefault...); err != nil {
		t.Errorf("Unable to randomize CvtermDbxref struct: %s", err)
	}

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

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

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


示例16: testPubRelationshipsAll

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

	seed := randomize.NewSeed()
	var err error
	pubRelationshipOne := &PubRelationship{}
	pubRelationshipTwo := &PubRelationship{}
	if err = randomize.Struct(seed, pubRelationshipOne, pubRelationshipDBTypes, false, pubRelationshipColumnsWithDefault...); err != nil {
		t.Errorf("Unable to randomize PubRelationship struct: %s", err)
	}
	if err = randomize.Struct(seed, pubRelationshipTwo, pubRelationshipDBTypes, false, pubRelationshipColumnsWithDefault...); err != nil {
		t.Errorf("Unable to randomize PubRelationship struct: %s", err)
	}

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

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

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


示例17: testStockDbxrefOneToOneSetOpStockDbxrefpropUsingStockDbxrefprop

func testStockDbxrefOneToOneSetOpStockDbxrefpropUsingStockDbxrefprop(t *testing.T) {
	var err error

	tx := MustTx(boil.Begin())
	defer tx.Rollback()

	var a StockDbxref
	var b, c StockDbxrefprop

	seed := randomize.NewSeed()
	if err = randomize.Struct(seed, &a, stockDbxrefDBTypes, false, strmangle.SetComplement(stockDbxrefPrimaryKeyColumns, stockDbxrefColumnsWithoutDefault)...); err != nil {
		t.Fatal(err)
	}
	if err = randomize.Struct(seed, &b, stockDbxrefpropDBTypes, false, strmangle.SetComplement(stockDbxrefpropPrimaryKeyColumns, stockDbxrefpropColumnsWithoutDefault)...); err != nil {
		t.Fatal(err)
	}
	if err = randomize.Struct(seed, &c, stockDbxrefpropDBTypes, false, strmangle.SetComplement(stockDbxrefpropPrimaryKeyColumns, stockDbxrefpropColumnsWithoutDefault)...); err != nil {
		t.Fatal(err)
	}

	if err := a.Insert(tx); err != nil {
		t.Fatal(err)
	}
	if err = b.Insert(tx); err != nil {
		t.Fatal(err)
	}

	for i, x := range []*StockDbxrefprop{&b, &c} {
		err = a.SetStockDbxrefprop(tx, i != 0, x)
		if err != nil {
			t.Fatal(err)
		}

		if a.R.StockDbxrefprop != x {
			t.Error("relationship struct not set to correct value")
		}
		if x.R.StockDbxref != &a {
			t.Error("failed to append to foreign relationship struct")
		}

		if a.StockDbxrefID != x.StockDbxrefID {
			t.Error("foreign key was wrong value", a.StockDbxrefID)
		}

		zero := reflect.Zero(reflect.TypeOf(x.StockDbxrefID))
		reflect.Indirect(reflect.ValueOf(&x.StockDbxrefID)).Set(zero)

		if err = x.Reload(tx); err != nil {
			t.Fatal("failed to reload", err)
		}

		if a.StockDbxrefID != x.StockDbxrefID {
			t.Error("foreign key was wrong value", a.StockDbxrefID, x.StockDbxrefID)
		}

		if err = x.Delete(tx); err != nil {
			t.Fatal("failed to delete x", err)
		}
	}
}
开发者ID:dictyBase,项目名称:Modware,代码行数:60,代码来源:stock_dbxref_test.go


示例18: testFeatureCvtermOneToOneSetOpFeatureCvtermPubUsingFeatureCvtermPub

func testFeatureCvtermOneToOneSetOpFeatureCvtermPubUsingFeatureCvtermPub(t *testing.T) {
	var err error

	tx := MustTx(boil.Begin())
	defer tx.Rollback()

	var a FeatureCvterm
	var b, c FeatureCvtermPub

	seed := randomize.NewSeed()
	if err = randomize.Struct(seed, &a, featureCvtermDBTypes, false, strmangle.SetComplement(featureCvtermPrimaryKeyColumns, featureCvtermColumnsWithoutDefault)...); err != nil {
		t.Fatal(err)
	}
	if err = randomize.Struct(seed, &b, featureCvtermPubDBTypes, false, strmangle.SetComplement(featureCvtermPubPrimaryKeyColumns, featureCvtermPubColumnsWithoutDefault)...); err != nil {
		t.Fatal(err)
	}
	if err = randomize.Struct(seed, &c, featureCvtermPubDBTypes, false, strmangle.SetComplement(featureCvtermPubPrimaryKeyColumns, featureCvtermPubColumnsWithoutDefault)...); err != nil {
		t.Fatal(err)
	}

	if err := a.Insert(tx); err != nil {
		t.Fatal(err)
	}
	if err = b.Insert(tx); err != nil {
		t.Fatal(err)
	}

	for i, x := range []*FeatureCvtermPub{&b, &c} {
		err = a.SetFeatureCvtermPub(tx, i != 0, x)
		if err != nil {
			t.Fatal(err)
		}

		if a.R.FeatureCvtermPub != x {
			t.Error("relationship struct not set to correct value")
		}
		if x.R.FeatureCvterm != &a {
			t.Error("failed to append to foreign relationship struct")
		}

		if a.FeatureCvtermID != x.FeatureCvtermID {
			t.Error("foreign key was wrong value", a.FeatureCvtermID)
		}

		zero := reflect.Zero(reflect.TypeOf(x.FeatureCvtermID))
		reflect.Indirect(reflect.ValueOf(&x.FeatureCvtermID)).Set(zero)

		if err = x.Reload(tx); err != nil {
			t.Fatal("failed to reload", err)
		}

		if a.FeatureCvtermID != x.FeatureCvtermID {
			t.Error("foreign key was wrong value", a.FeatureCvtermID, x.FeatureCvtermID)
		}

		if err = x.Delete(tx); err != nil {
			t.Fatal("failed to delete x", err)
		}
	}
}
开发者ID:dictyBase,项目名称:Modware,代码行数:60,代码来源:feature_cvterm_test.go


示例19: testFeatureRelationshippropPubsAll

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

	seed := randomize.NewSeed()
	var err error
	featureRelationshippropPubOne := &FeatureRelationshippropPub{}
	featureRelationshippropPubTwo := &FeatureRelationshippropPub{}
	if err = randomize.Struct(seed, featureRelationshippropPubOne, featureRelationshippropPubDBTypes, false, featureRelationshippropPubColumnsWithDefault...); err != nil {
		t.Errorf("Unable to randomize FeatureRelationshippropPub struct: %s", err)
	}
	if err = randomize.Struct(seed, featureRelationshippropPubTwo, featureRelationshippropPubDBTypes, false, featureRelationshippropPubColumnsWithDefault...); err != nil {
		t.Errorf("Unable to randomize FeatureRelationshippropPub struct: %s", err)
	}

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

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

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


示例20: testGenotypesAll

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

	seed := randomize.NewSeed()
	var err error
	genotypeOne := &Genotype{}
	genotypeTwo := &Genotype{}
	if err = randomize.Struct(seed, genotypeOne, genotypeDBTypes, false, genotypeColumnsWithDefault...); err != nil {
		t.Errorf("Unable to randomize Genotype struct: %s", err)
	}
	if err = randomize.Struct(seed, genotypeTwo, genotypeDBTypes, false, genotypeColumnsWithDefault...); err != nil {
		t.Errorf("Unable to randomize Genotype struct: %s", err)
	}

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

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

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



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Golang strmangle.GetBuffer函数代码示例发布时间:2022-05-28
下一篇:
Golang randomize.NewSeed函数代码示例发布时间: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