当前位置: 首页>>代码示例>>Golang>>正文


Golang randomize.Struct函数代码示例

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


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


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