當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。