How to use build method of main Package

Best Syzkaller code snippet using main.build

datatype_test.go

Source:datatype_test.go Github

copy

Full Screen

...6 "gitlab.com/verygoodsoftwarenotvirus/naff/lib/wordsmith"7 "github.com/Masterminds/squirrel"8 "github.com/stretchr/testify/assert"9)10func Test_buildFakeVarName(T *testing.T) {11 T.Parallel()12 T.Run("obligatory", func(t *testing.T) {13 t.Parallel()14 exampleInput := "fart"15 expected := "exampleFart"16 actual := buildFakeVarName(exampleInput)17 assert.Equal(t, expected, actual)18 })19}20func Test_ctxParam(T *testing.T) {21 T.Parallel()22 T.Run("obligatory", func(t *testing.T) {23 t.Parallel()24 out := jen.NewFile("main")25 out.Add(26 jen.Func().ID("test").Params(27 ctxParam(),28 ).Body(),29 )30 var b bytes.Buffer31 assert.NoError(t, out.Render(&b))32 expected := `33package main34import (35 "context"36)37func test(ctx context.Context) {}38`39 actual := "\n" + b.String()40 assert.Equal(t, expected, actual)41 })42}43func Test_ctxVar(T *testing.T) {44 T.Parallel()45 T.Run("obligatory", func(t *testing.T) {46 t.Parallel()47 out := jen.NewFile("main")48 out.Add(49 jen.Func().ID("test").Params().Body(50 ctxVar(),51 ),52 )53 var b bytes.Buffer54 assert.NoError(t, out.Render(&b))55 expected := `56package main57import ()58func test() {59 ctx60}61`62 actual := "\n" + b.String()63 assert.Equal(t, expected, actual)64 })65}66// DataType tests67func TestDataType_OwnedByAUserAtSomeLevel(T *testing.T) {68 T.Parallel()69 T.Run("simple", func(t *testing.T) {70 t.Parallel()71 dt := DataType{72 BelongsToUser: true,73 }74 p := &Project{75 DataTypes: []DataType{76 dt,77 },78 }79 assert.True(t, dt.OwnedByAUserAtSomeLevel(p))80 })81 T.Run("with multi-level ownership", func(t *testing.T) {82 t.Parallel()83 p := &Project{84 DataTypes: BuildOwnershipChain("A", "B", "C"),85 }86 p.DataTypes[0].BelongsToUser = true87 assert.True(t, p.LastDataType().OwnedByAUserAtSomeLevel(p))88 })89}90func TestDataType_RestrictedToUserAtSomeLevel(T *testing.T) {91 T.Parallel()92 T.Run("simple", func(t *testing.T) {93 t.Parallel()94 dt := DataType{95 BelongsToUser: true,96 RestrictedToUser: true,97 }98 p := &Project{99 DataTypes: []DataType{100 dt,101 },102 }103 assert.True(t, dt.RestrictedToUserAtSomeLevel(p))104 })105 T.Run("with multi-level ownership", func(t *testing.T) {106 t.Parallel()107 dtA := DataType{108 Name: wordsmith.FromSingularPascalCase("A"),109 BelongsToUser: true,110 RestrictedToUser: true,111 }112 dtB := DataType{113 Name: wordsmith.FromSingularPascalCase("B"),114 BelongsToStruct: wordsmith.FromSingularPascalCase("A"),115 }116 dtC := DataType{117 Name: wordsmith.FromSingularPascalCase("C"),118 BelongsToStruct: wordsmith.FromSingularPascalCase("B"),119 }120 p := &Project{121 DataTypes: []DataType{122 dtA,123 dtB,124 dtC,125 },126 }127 assert.True(t, dtC.RestrictedToUserAtSomeLevel(p))128 })129}130func TestDataType_MultipleOwnersBelongingToUser(T *testing.T) {131 T.Parallel()132 T.Run("with multi-level ownership", func(t *testing.T) {133 t.Parallel()134 dtA := DataType{135 Name: wordsmith.FromSingularPascalCase("A"),136 BelongsToUser: true,137 }138 dtB := DataType{139 Name: wordsmith.FromSingularPascalCase("B"),140 BelongsToUser: true,141 BelongsToStruct: wordsmith.FromSingularPascalCase("A"),142 }143 dtC := DataType{144 Name: wordsmith.FromSingularPascalCase("C"),145 BelongsToUser: true,146 BelongsToStruct: wordsmith.FromSingularPascalCase("B"),147 }148 p := &Project{149 DataTypes: []DataType{150 dtA,151 dtB,152 dtC,153 },154 }155 assert.True(t, dtC.MultipleOwnersBelongingToUser(p))156 })157}158func TestDataType_buildGetSomethingParams(T *testing.T) {159 T.Parallel()160 T.Run("simple", func(t *testing.T) {161 t.Parallel()162 p := buildExampleTodoListProject()163 p.DataTypes = BuildOwnershipChain("Thing", "AnotherThing", "YetAnotherThing")164 p.DataTypes[0].BelongsToUser = true165 p.DataTypes[0].RestrictedToUser = true166 expected := `167package main168import (169 "context"170)171func example(ctx context.Context, thingID, anotherThingID, yetAnotherThingID, userID uint64) {}172`173 actual := renderFunctionParamsToString(t, p.LastDataType().buildGetSomethingParams(p))174 assert.Equal(t, expected, actual)175 })176}177func TestDataType_buildArchiveSomethingParams(T *testing.T) {178 T.Parallel()179 T.Run("simple", func(t *testing.T) {180 t.Parallel()181 dt := DataType{182 BelongsToStruct: wordsmith.FromSingularPascalCase("Thing"),183 Name: wordsmith.FromSingularPascalCase("AnotherThing"),184 BelongsToUser: true,185 RestrictedToUser: true,186 }187 expected := `188package main189import (190 "context"191)192func example(ctx context.Context, thingID, anotherThingID, userID uint64) {}193`194 actual := renderFunctionParamsToString(t, dt.buildArchiveSomethingParams())195 assert.Equal(t, expected, actual)196 })197}198func TestDataType_BuildInterfaceDefinitionExistenceMethodParams(T *testing.T) {199 T.Parallel()200 T.Run("simple", func(t *testing.T) {201 t.Parallel()202 dt := DataType{203 Name: wordsmith.FromSingularPascalCase("Thing"),204 }205 p := buildExampleTodoListProject()206 expected := `207package main208import (209 "context"210)211func example(ctx context.Context, thingID uint64) {}212`213 actual := renderFunctionParamsToString(t, dt.BuildInterfaceDefinitionExistenceMethodParams(p))214 assert.Equal(t, expected, actual)215 })216}217func TestDataType_BuildInterfaceDefinitionRetrievalMethodParams(T *testing.T) {218 T.Parallel()219 T.Run("simple", func(t *testing.T) {220 t.Parallel()221 dt := DataType{222 Name: wordsmith.FromSingularPascalCase("Thing"),223 }224 p := buildExampleTodoListProject()225 expected := `226package main227import (228 "context"229)230func example(ctx context.Context, thingID uint64) {}231`232 actual := renderFunctionParamsToString(t, dt.BuildInterfaceDefinitionRetrievalMethodParams(p))233 assert.Equal(t, expected, actual)234 })235}236func TestDataType_BuildInterfaceDefinitionArchiveMethodParams(T *testing.T) {237 T.Parallel()238 T.Run("simple", func(t *testing.T) {239 t.Parallel()240 dt := DataType{241 Name: wordsmith.FromSingularPascalCase("Thing"),242 }243 expected := `244package main245import (246 "context"247)248func example(ctx context.Context, thingID uint64) {}249`250 actual := renderFunctionParamsToString(t, dt.BuildInterfaceDefinitionArchiveMethodParams())251 assert.Equal(t, expected, actual)252 })253}254func TestDataType_BuildDBClientArchiveMethodParams(T *testing.T) {255 T.Parallel()256 T.Run("simple", func(t *testing.T) {257 t.Parallel()258 dt := DataType{259 Name: wordsmith.FromSingularPascalCase("Thing"),260 }261 expected := `262package main263import (264 "context"265)266func example(ctx context.Context, thingID uint64) {}267`268 actual := renderFunctionParamsToString(t, dt.BuildDBClientArchiveMethodParams())269 assert.Equal(t, expected, actual)270 })271}272func TestDataType_BuildDBClientRetrievalMethodParams(T *testing.T) {273 T.Parallel()274 T.Run("simple", func(t *testing.T) {275 t.Parallel()276 dt := DataType{277 Name: wordsmith.FromSingularPascalCase("Thing"),278 }279 p := buildExampleTodoListProject()280 expected := `281package main282import (283 "context"284)285func example(ctx context.Context, thingID uint64) {}286`287 actual := renderFunctionParamsToString(t, dt.BuildDBClientRetrievalMethodParams(p))288 assert.Equal(t, expected, actual)289 })290}291func TestDataType_BuildDBClientExistenceMethodParams(T *testing.T) {292 T.Parallel()293 T.Run("simple", func(t *testing.T) {294 t.Parallel()295 dt := DataType{296 Name: wordsmith.FromSingularPascalCase("Thing"),297 }298 p := buildExampleTodoListProject()299 expected := `300package main301import (302 "context"303)304func example(ctx context.Context, thingID uint64) {}305`306 actual := renderFunctionParamsToString(t, dt.BuildDBClientExistenceMethodParams(p))307 assert.Equal(t, expected, actual)308 })309}310func TestDataType_BuildDBQuerierArchiveMethodParams(T *testing.T) {311 T.Parallel()312 T.Run("simple", func(t *testing.T) {313 t.Parallel()314 dt := DataType{315 Name: wordsmith.FromSingularPascalCase("Thing"),316 }317 expected := `318package main319import (320 "context"321)322func example(ctx context.Context, thingID uint64) {}323`324 actual := renderFunctionParamsToString(t, dt.BuildDBQuerierArchiveMethodParams())325 assert.Equal(t, expected, actual)326 })327}328func TestDataType_BuildDBQuerierArchiveQueryMethodParams(T *testing.T) {329 T.Parallel()330 T.Run("simple", func(t *testing.T) {331 t.Parallel()332 dt := DataType{333 Name: wordsmith.FromSingularPascalCase("Thing"),334 }335 expected := `336package main337import ()338func example(thingID uint64) {}339`340 actual := renderFunctionParamsToString(t, dt.BuildDBQuerierArchiveQueryMethodParams())341 assert.Equal(t, expected, actual)342 })343}344func TestDataType_BuildDBQuerierRetrievalMethodParams(T *testing.T) {345 T.Parallel()346 T.Run("simple", func(t *testing.T) {347 t.Parallel()348 dt := DataType{349 Name: wordsmith.FromSingularPascalCase("Thing"),350 }351 p := buildExampleTodoListProject()352 expected := `353package main354import ()355func example(thingID uint64) {}356`357 actual := renderFunctionParamsToString(t, dt.BuildDBQuerierRetrievalMethodParams(p))358 assert.Equal(t, expected, actual)359 })360}361func TestDataType_BuildDBQuerierRetrievalQueryMethodParams(T *testing.T) {362 T.Parallel()363 T.Run("simple", func(t *testing.T) {364 t.Parallel()365 dt := DataType{366 Name: wordsmith.FromSingularPascalCase("Thing"),367 }368 p := buildExampleTodoListProject()369 expected := `370package main371import (372 "context"373)374func example(ctx context.Context, thingID uint64) {}375`376 actual := renderFunctionParamsToString(t, dt.BuildDBQuerierRetrievalQueryMethodParams(p))377 assert.Equal(t, expected, actual)378 })379}380func TestDataType_BuildDBQuerierExistenceQueryMethodParams(T *testing.T) {381 T.Parallel()382 T.Run("simple", func(t *testing.T) {383 t.Parallel()384 dt := DataType{385 Name: wordsmith.FromSingularPascalCase("Thing"),386 }387 p := buildExampleTodoListProject()388 expected := `389package main390import ()391func example(thingID uint64) {}392`393 actual := renderFunctionParamsToString(t, dt.BuildDBQuerierExistenceQueryMethodParams(p))394 assert.Equal(t, expected, actual)395 })396}397func TestDataType_ModifyQueryBuildingStatementWithJoinClauses(T *testing.T) {398 T.Parallel()399 T.Run("obligatory", func(t *testing.T) {400 t.Parallel()401 p := buildExampleTodoListProject()402 p.DataTypes = BuildOwnershipChain("Thing", "AnotherThing", "YetAnotherThing", "EvenStillAnotherThing")403 result := p.LastDataType().ModifyQueryBuildingStatementWithJoinClauses(p, jen.ID("something"))404 expected := `405package main406import ()407func main() {408 something.409 Join(yetAnotherThingsOnEvenStillAnotherThingsJoinClause).410 Join(anotherThingsOnYetAnotherThingsJoinClause).411 Join(thingsOnAnotherThingsJoinClause)412}413`414 actual := renderIndependentStatementToString(t, result)415 assert.Equal(t, expected, actual)416 })417}418func TestDataType_buildJoinClause(T *testing.T) {419 T.Parallel()420 T.Run("obligatory", func(t *testing.T) {421 t.Parallel()422 dt := DataType{423 Name: wordsmith.FromSingularPascalCase("Thing"),424 BelongsToStruct: wordsmith.FromSingularPascalCase("SomethingElse"),425 }426 expected := "table1 ON table2.belongs_to_table3=table1.id"427 actual := dt.buildJoinClause("table1", "table2", "table3")428 assert.Equal(t, expected, actual)429 })430 T.Run("panics on non-ownership", func(t *testing.T) {431 t.Parallel()432 dt := DataType{433 Name: wordsmith.FromSingularPascalCase("Thing"),434 }435 defer func() {436 if r := recover(); r == nil {437 t.Error("expected panic did not occur!")438 }439 }()440 dt.buildJoinClause("table1", "table2", "table3")441 })442}443func TestDataType_ModifyQueryBuilderWithJoinClauses(T *testing.T) {444 T.Parallel()445 T.Run("obligatory", func(t *testing.T) {446 t.Parallel()447 p := buildExampleTodoListProject()448 p.DataTypes = BuildOwnershipChain("Thing", "AnotherThing", "YetAnotherThing")449 s := squirrel.Select("*").From("fart")450 result := p.LastDataType().ModifyQueryBuilderWithJoinClauses(p, s)451 expected := "SELECT * FROM fart JOIN another_things ON yet_another_things.belongs_to_another_thing=another_things.id JOIN things ON another_things.belongs_to_thing=things.id"452 actual, _, err := result.ToSql()453 assert.NoError(t, err)454 assert.Equal(t, expected, actual)455 })456}457func TestDataType_buildDBQuerierSingleInstanceQueryMethodConditionalClauses(T *testing.T) {458 T.Parallel()459 T.Run("obligatory", func(t *testing.T) {460 t.Parallel()461 dt := DataType{462 Name: wordsmith.FromSingularPascalCase("Thing"),463 }464 p := buildExampleTodoListProject()465 result := dt.buildDBQuerierSingleInstanceQueryMethodConditionalClauses(p)466 expected := `467package main468import (469 "fmt"470)471func main() {472 exampleMap := map[string]interface{}{473 fmt.Sprintf("%s.%s", thingsTableName, idColumn): thingID,474 }475}476`477 actual := renderMapEntriesWithStringKeysToString(t, result)478 assert.Equal(t, expected, actual)479 })480 T.Run("with multiple ownerships", func(t *testing.T) {481 t.Parallel()482 p := buildExampleTodoListProject()483 p.DataTypes = BuildOwnershipChain("Thing", "AnotherThing", "YetAnotherThing")484 for i := range p.DataTypes {485 p.DataTypes[i].BelongsToUser = true486 p.DataTypes[i].RestrictedToUser = true487 }488 result := p.LastDataType().buildDBQuerierSingleInstanceQueryMethodConditionalClauses(p)489 expected := `490package main491import (492 "fmt"493)494func main() {495 exampleMap := map[string]interface{}{496 fmt.Sprintf("%s.%s", yetAnotherThingsTableName, idColumn): yetAnotherThingID,497 fmt.Sprintf("%s.%s", thingsTableName, idColumn): thingID,498 fmt.Sprintf("%s.%s", thingsTableName, thingsUserOwnershipColumn): userID,499 fmt.Sprintf("%s.%s", anotherThingsTableName, idColumn): anotherThingID,500 fmt.Sprintf("%s.%s", anotherThingsTableName, anotherThingsUserOwnershipColumn): userID,501 fmt.Sprintf("%s.%s", anotherThingsTableName, anotherThingsTableOwnershipColumn): thingID,502 fmt.Sprintf("%s.%s", yetAnotherThingsTableName, yetAnotherThingsTableOwnershipColumn): anotherThingID,503 fmt.Sprintf("%s.%s", yetAnotherThingsTableName, yetAnotherThingsUserOwnershipColumn): userID,504 }505}506`507 actual := renderMapEntriesWithStringKeysToString(t, result)508 assert.Equal(t, expected, actual)509 })510}511func TestDataType_BuildDBQuerierExistenceQueryMethodConditionalClauses(T *testing.T) {512 T.Parallel()513 T.Run("obligatory", func(t *testing.T) {514 t.Parallel()515 dt := DataType{516 Name: wordsmith.FromSingularPascalCase("Thing"),517 }518 p := buildExampleTodoListProject()519 result := dt.BuildDBQuerierExistenceQueryMethodConditionalClauses(p)520 expected := `521package main522import (523 "fmt"524)525func main() {526 exampleMap := map[string]interface{}{527 fmt.Sprintf("%s.%s", thingsTableName, idColumn): thingID,528 }529}530`531 actual := renderMapEntriesWithStringKeysToString(t, result)532 assert.Equal(t, expected, actual)533 })534}535func TestDataType_buildDBQuerierSingleInstanceQueryMethodQueryBuildingClauses(T *testing.T) {536 T.Parallel()537 T.Run("obligatory", func(t *testing.T) {538 t.Parallel()539 dt := DataType{540 Name: wordsmith.FromSingularPascalCase("Thing"),541 }542 p := buildExampleTodoListProject()543 results := dt.buildDBQuerierSingleInstanceQueryMethodQueryBuildingClauses(p)544 qb := squirrel.Select("*").From("farts").Where(results)545 expected := "SELECT * FROM farts WHERE things.id = ?"546 actual, _, err := qb.ToSql()547 assert.NoError(t, err)548 assert.Equal(t, expected, actual)549 })550 T.Run("with multiple ownerships", func(t *testing.T) {551 t.Parallel()552 p := buildExampleTodoListProject()553 p.DataTypes = BuildOwnershipChain("Thing", "AnotherThing", "YetAnotherThing")554 for i := range p.DataTypes {555 p.DataTypes[i].BelongsToUser = true556 p.DataTypes[i].RestrictedToUser = true557 }558 results := p.LastDataType().buildDBQuerierSingleInstanceQueryMethodQueryBuildingClauses(p)559 qb := squirrel.Select("*").From("farts").Where(results)560 expected := "SELECT * FROM farts WHERE another_things.belongs_to_thing = ? AND another_things.belongs_to_user = ? AND another_things.id = ? AND things.belongs_to_user = ? AND things.id = ? AND yet_another_things.belongs_to_another_thing = ? AND yet_another_things.belongs_to_user = ? AND yet_another_things.id = ?"561 actual, _, err := qb.ToSql()562 assert.NoError(t, err)563 assert.Equal(t, expected, actual)564 })565}566func TestDataType_BuildDBQuerierExistenceQueryMethodQueryBuildingWhereClause(T *testing.T) {567 T.Parallel()568 T.Run("obligatory", func(t *testing.T) {569 t.Parallel()570 dt := DataType{571 Name: wordsmith.FromSingularPascalCase("Thing"),572 }573 p := buildExampleTodoListProject()574 results := dt.BuildDBQuerierExistenceQueryMethodQueryBuildingWhereClause(p)575 qb := squirrel.Select("*").From("farts").Where(results)576 expected := "SELECT * FROM farts WHERE things.id = ?"577 actual, _, err := qb.ToSql()578 assert.NoError(t, err)579 assert.Equal(t, expected, actual)580 })581}582func TestDataType_BuildDBQuerierRetrievalQueryMethodQueryBuildingWhereClause(T *testing.T) {583 T.Parallel()584 T.Run("obligatory", func(t *testing.T) {585 t.Parallel()586 dt := DataType{587 Name: wordsmith.FromSingularPascalCase("Thing"),588 }589 p := buildExampleTodoListProject()590 results := dt.BuildDBQuerierRetrievalQueryMethodQueryBuildingWhereClause(p)591 qb := squirrel.Select("*").From("farts").Where(results)592 expected := "SELECT * FROM farts WHERE things.id = ?"593 actual, _, err := qb.ToSql()594 assert.NoError(t, err)595 assert.Equal(t, expected, actual)596 })597}598func TestDataType_BuildDBQuerierListRetrievalQueryMethodQueryBuildingWhereClause(T *testing.T) {599 T.Parallel()600 T.Run("obligatory", func(t *testing.T) {601 t.Parallel()602 dt := DataType{603 Name: wordsmith.FromSingularPascalCase("Thing"),604 }605 p := buildExampleTodoListProject()606 results := dt.BuildDBQuerierListRetrievalQueryMethodQueryBuildingWhereClause(p)607 qb := squirrel.Select("*").From("farts").Where(results)608 expected := "SELECT * FROM farts WHERE things.archived_on IS NULL"609 actual, _, err := qb.ToSql()610 assert.NoError(t, err)611 assert.Equal(t, expected, actual)612 })613 T.Run("with multiple ownerships", func(t *testing.T) {614 t.Parallel()615 p := buildExampleTodoListProject()616 p.DataTypes = BuildOwnershipChain("Thing", "AnotherThing", "YetAnotherThing")617 for i := range p.DataTypes {618 p.DataTypes[i].BelongsToUser = true619 p.DataTypes[i].RestrictedToUser = true620 }621 results := p.LastDataType().BuildDBQuerierListRetrievalQueryMethodQueryBuildingWhereClause(p)622 qb := squirrel.Select("*").From("farts").Where(results)623 expected := "SELECT * FROM farts WHERE another_things.belongs_to_thing = ? AND another_things.belongs_to_user = ? AND another_things.id = ? AND things.belongs_to_user = ? AND things.id = ? AND yet_another_things.archived_on IS NULL AND yet_another_things.belongs_to_another_thing = ? AND yet_another_things.belongs_to_user = ?"624 actual, _, err := qb.ToSql()625 assert.NoError(t, err)626 assert.Equal(t, expected, actual)627 })628}629func TestDataType_BuildDBQuerierRetrievalQueryMethodConditionalClauses(T *testing.T) {630 T.Parallel()631 T.Run("obligatory", func(t *testing.T) {632 t.Parallel()633 dt := DataType{634 Name: wordsmith.FromSingularPascalCase("Thing"),635 }636 p := buildExampleTodoListProject()637 expected := `638package main639import (640 "fmt"641)642func main() {643 exampleMap := map[string]interface{}{644 fmt.Sprintf("%s.%s", thingsTableName, idColumn): thingID,645 }646}647`648 actual := renderMapEntriesWithStringKeysToString(t, dt.BuildDBQuerierRetrievalQueryMethodConditionalClauses(p))649 assert.Equal(t, expected, actual)650 })651 T.Run("with multiple ownerships", func(t *testing.T) {652 t.Parallel()653 p := buildExampleTodoListProject()654 p.DataTypes = BuildOwnershipChain("Thing", "AnotherThing", "YetAnotherThing")655 for i := range p.DataTypes {656 p.DataTypes[i].BelongsToUser = true657 p.DataTypes[i].RestrictedToUser = true658 }659 expected := `660package main661import (662 "fmt"663)664func main() {665 exampleMap := map[string]interface{}{666 fmt.Sprintf("%s.%s", yetAnotherThingsTableName, idColumn): yetAnotherThingID,667 fmt.Sprintf("%s.%s", thingsTableName, idColumn): thingID,668 fmt.Sprintf("%s.%s", thingsTableName, thingsUserOwnershipColumn): userID,669 fmt.Sprintf("%s.%s", anotherThingsTableName, idColumn): anotherThingID,670 fmt.Sprintf("%s.%s", anotherThingsTableName, anotherThingsUserOwnershipColumn): userID,671 fmt.Sprintf("%s.%s", anotherThingsTableName, anotherThingsTableOwnershipColumn): thingID,672 fmt.Sprintf("%s.%s", yetAnotherThingsTableName, yetAnotherThingsTableOwnershipColumn): anotherThingID,673 fmt.Sprintf("%s.%s", yetAnotherThingsTableName, yetAnotherThingsUserOwnershipColumn): userID,674 }675}676`677 actual := renderMapEntriesWithStringKeysToString(t, p.LastDataType().BuildDBQuerierRetrievalQueryMethodConditionalClauses(p))678 assert.Equal(t, expected, actual)679 })680}681func TestDataType_BuildDBQuerierListRetrievalQueryMethodConditionalClauses(T *testing.T) {682 T.Parallel()683 T.Run("obligatory", func(t *testing.T) {684 t.Parallel()685 dt := DataType{686 Name: wordsmith.FromSingularPascalCase("Thing"),687 }688 p := buildExampleTodoListProject()689 expected := `690package main691import (692 "fmt"693)694func main() {695 exampleMap := map[string]interface{}{696 fmt.Sprintf("%s.%s", thingsTableName, archivedOnColumn): nil,697 }698}699`700 actual := renderMapEntriesWithStringKeysToString(t, dt.BuildDBQuerierListRetrievalQueryMethodConditionalClauses(p))701 assert.Equal(t, expected, actual)702 })703 T.Run("with multiple ownerships", func(t *testing.T) {704 t.Parallel()705 p := buildExampleTodoListProject()706 p.DataTypes = BuildOwnershipChain("Thing", "AnotherThing", "YetAnotherThing")707 for i := range p.DataTypes {708 p.DataTypes[i].BelongsToUser = true709 p.DataTypes[i].RestrictedToUser = true710 }711 expected := `712package main713import (714 "fmt"715)716func main() {717 exampleMap := map[string]interface{}{718 fmt.Sprintf("%s.%s", yetAnotherThingsTableName, archivedOnColumn): nil,719 fmt.Sprintf("%s.%s", thingsTableName, idColumn): thingID,720 fmt.Sprintf("%s.%s", thingsTableName, thingsUserOwnershipColumn): userID,721 fmt.Sprintf("%s.%s", anotherThingsTableName, idColumn): anotherThingID,722 fmt.Sprintf("%s.%s", anotherThingsTableName, anotherThingsUserOwnershipColumn): userID,723 fmt.Sprintf("%s.%s", anotherThingsTableName, anotherThingsTableOwnershipColumn): thingID,724 fmt.Sprintf("%s.%s", yetAnotherThingsTableName, yetAnotherThingsTableOwnershipColumn): anotherThingID,725 fmt.Sprintf("%s.%s", yetAnotherThingsTableName, yetAnotherThingsUserOwnershipColumn): userID,726 }727}728`729 actual := renderMapEntriesWithStringKeysToString(t, p.LastDataType().BuildDBQuerierListRetrievalQueryMethodConditionalClauses(p))730 assert.Equal(t, expected, actual)731 })732}733func TestDataType_BuildDBQuerierExistenceMethodParams(T *testing.T) {734 T.Parallel()735 T.Run("simple", func(t *testing.T) {736 t.Parallel()737 dt := DataType{738 Name: wordsmith.FromSingularPascalCase("Thing"),739 }740 p := buildExampleTodoListProject()741 expected := `742package main743import (744 "context"745)746func example(ctx context.Context, thingID uint64) {}747`748 actual := renderFunctionParamsToString(t, dt.BuildDBQuerierExistenceMethodParams(p))749 assert.Equal(t, expected, actual)750 })751}752func TestDataType_buildGetSomethingArgs(T *testing.T) {753 T.Parallel()754 T.Run("obligatory", func(t *testing.T) {755 t.Parallel()756 dt := DataType{757 Name: wordsmith.FromSingularPascalCase("Thing"),758 }759 p := buildExampleTodoListProject()760 expected := `761package main762import ()763func main() {764 exampleFunction(ctx, thingID)765}766`767 actual := renderCallArgsToString(t, dt.buildGetSomethingArgs(p))768 assert.Equal(t, expected, actual)769 })770 T.Run("with multiple ownerships", func(t *testing.T) {771 t.Parallel()772 p := buildExampleTodoListProject()773 p.DataTypes = BuildOwnershipChain("Thing", "AnotherThing", "YetAnotherThing")774 for i := range p.DataTypes {775 p.DataTypes[i].BelongsToUser = true776 p.DataTypes[i].RestrictedToUser = true777 }778 expected := `779package main780import ()781func main() {782 exampleFunction(ctx, thingID, anotherThingID, yetAnotherThingID, userID)783}784`785 actual := renderCallArgsToString(t, p.LastDataType().buildGetSomethingArgs(p))786 assert.Equal(t, expected, actual)787 })788}789func TestDataType_buildArchiveSomethingArgs(T *testing.T) {790 T.Parallel()791 T.Run("obligatory", func(t *testing.T) {792 t.Parallel()793 dt := DataType{794 Name: wordsmith.FromSingularPascalCase("Thing"),795 }796 expected := `797package main798import ()799func main() {800 exampleFunction(ctx, thingID)801}802`803 actual := renderCallArgsToString(t, dt.buildArchiveSomethingArgs())804 assert.Equal(t, expected, actual)805 })806 T.Run("with ownership", func(t *testing.T) {807 t.Parallel()808 dt := DataType{809 BelongsToStruct: wordsmith.FromSingularPascalCase("Thing"),810 Name: wordsmith.FromSingularPascalCase("AnotherThing"),811 BelongsToUser: true,812 }813 expected := `814package main815import ()816func main() {817 exampleFunction(ctx, thingID, anotherThingID, userID)818}819`820 actual := renderCallArgsToString(t, dt.buildArchiveSomethingArgs())821 assert.Equal(t, expected, actual)822 })823}824func TestDataType_BuildDBClientExistenceMethodCallArgs(T *testing.T) {825 T.Parallel()826 T.Run("obligatory", func(t *testing.T) {827 t.Parallel()828 dt := DataType{829 Name: wordsmith.FromSingularPascalCase("Thing"),830 }831 p := buildExampleTodoListProject()832 expected := `833package main834import ()835func main() {836 exampleFunction(ctx, thingID)837}838`839 actual := renderCallArgsToString(t, dt.BuildDBClientExistenceMethodCallArgs(p))840 assert.Equal(t, expected, actual)841 })842}843func TestDataType_BuildDBClientRetrievalMethodCallArgs(T *testing.T) {844 T.Parallel()845 T.Run("obligatory", func(t *testing.T) {846 t.Parallel()847 dt := DataType{848 Name: wordsmith.FromSingularPascalCase("Thing"),849 }850 p := buildExampleTodoListProject()851 expected := `852package main853import ()854func main() {855 exampleFunction(ctx, thingID)856}857`858 actual := renderCallArgsToString(t, dt.BuildDBClientRetrievalMethodCallArgs(p))859 assert.Equal(t, expected, actual)860 })861}862func TestDataType_BuildDBClientArchiveMethodCallArgs(T *testing.T) {863 T.Parallel()864 T.Run("obligatory", func(t *testing.T) {865 t.Parallel()866 dt := DataType{867 Name: wordsmith.FromSingularPascalCase("Thing"),868 }869 expected := `870package main871import ()872func main() {873 exampleFunction(ctx, thingID)874}875`876 actual := renderCallArgsToString(t, dt.BuildDBClientArchiveMethodCallArgs())877 assert.Equal(t, expected, actual)878 })879}880func TestDataType_BuildDBQuerierExistenceQueryBuildingArgs(T *testing.T) {881 T.Parallel()882 T.Run("obligatory", func(t *testing.T) {883 t.Parallel()884 dt := DataType{885 Name: wordsmith.FromSingularPascalCase("Thing"),886 }887 p := buildExampleTodoListProject()888 expected := `889package main890import ()891func main() {892 exampleFunction(thingID)893}894`895 actual := renderCallArgsToString(t, dt.BuildDBQuerierExistenceQueryBuildingArgs(p))896 assert.Equal(t, expected, actual)897 })898}899func TestDataType_BuildDBQuerierRetrievalQueryBuildingArgs(T *testing.T) {900 T.Parallel()901 T.Run("obligatory", func(t *testing.T) {902 t.Parallel()903 dt := DataType{904 Name: wordsmith.FromSingularPascalCase("Thing"),905 }906 p := buildExampleTodoListProject()907 expected := `908package main909import ()910func main() {911 exampleFunction(thingID)912}913`914 actual := renderCallArgsToString(t, dt.BuildDBQuerierRetrievalQueryBuildingArgs(p))915 assert.Equal(t, expected, actual)916 })917}918func TestDataType_BuildDBQuerierArchiveQueryBuildingArgs(T *testing.T) {919 T.Parallel()920 T.Run("obligatory", func(t *testing.T) {921 t.Parallel()922 dt := DataType{923 Name: wordsmith.FromSingularPascalCase("Thing"),924 }925 expected := `926package main927import ()928func main() {929 exampleFunction(thingID)930}931`932 actual := renderCallArgsToString(t, dt.BuildDBQuerierArchiveQueryBuildingArgs())933 assert.Equal(t, expected, actual)934 })935}936func TestDataType_BuildInterfaceDefinitionExistenceMethodCallArgs(T *testing.T) {937 T.Parallel()938 T.Run("obligatory", func(t *testing.T) {939 t.Parallel()940 dt := DataType{941 Name: wordsmith.FromSingularPascalCase("Thing"),942 }943 p := buildExampleTodoListProject()944 expected := `945package main946import ()947func main() {948 exampleFunction(ctx, thingID)949}950`951 actual := renderCallArgsToString(t, dt.BuildInterfaceDefinitionExistenceMethodCallArgs(p))952 assert.Equal(t, expected, actual)953 })954}955func TestDataType_BuildInterfaceDefinitionRetrievalMethodCallArgs(T *testing.T) {956 T.Parallel()957 T.Run("obligatory", func(t *testing.T) {958 t.Parallel()959 dt := DataType{960 Name: wordsmith.FromSingularPascalCase("Thing"),961 }962 p := buildExampleTodoListProject()963 expected := `964package main965import ()966func main() {967 exampleFunction(ctx, thingID)968}969`970 actual := renderCallArgsToString(t, dt.BuildInterfaceDefinitionRetrievalMethodCallArgs(p))971 assert.Equal(t, expected, actual)972 })973}974func TestDataType_BuildInterfaceDefinitionArchiveMethodCallArgs(T *testing.T) {975 T.Parallel()976 T.Run("obligatory", func(t *testing.T) {977 t.Parallel()978 dt := DataType{979 Name: wordsmith.FromSingularPascalCase("Thing"),980 }981 expected := `982package main983import ()984func main() {985 exampleFunction(ctx, thingID)986}987`988 actual := renderCallArgsToString(t, dt.BuildInterfaceDefinitionArchiveMethodCallArgs())989 assert.Equal(t, expected, actual)990 })991}992func TestDataType_buildGetSomethingArgsWithExampleVariables(T *testing.T) {993 T.Parallel()994 T.Run("while including context", func(t *testing.T) {995 t.Parallel()996 dt := DataType{997 Name: wordsmith.FromSingularPascalCase("Thing"),998 }999 p := buildExampleTodoListProject()1000 expected := `1001package main1002import ()1003func main() {1004 exampleFunction(ctx, exampleThing.ID)1005}1006`1007 actual := renderCallArgsToString(t, dt.buildGetSomethingArgsWithExampleVariables(p, true))1008 assert.Equal(t, expected, actual)1009 })1010 T.Run("without including context", func(t *testing.T) {1011 t.Parallel()1012 dt := DataType{1013 Name: wordsmith.FromSingularPascalCase("Thing"),1014 }1015 p := buildExampleTodoListProject()1016 expected := `1017package main1018import ()1019func main() {1020 exampleFunction(exampleThing.ID)1021}1022`1023 actual := renderCallArgsToString(t, dt.buildGetSomethingArgsWithExampleVariables(p, false))1024 assert.Equal(t, expected, actual)1025 })1026 T.Run("with multiple ownership", func(t *testing.T) {1027 t.Parallel()1028 p := buildExampleTodoListProject()1029 p.DataTypes = BuildOwnershipChain("Thing", "AnotherThing", "YetAnotherThing")1030 for i := range p.DataTypes {1031 p.DataTypes[i].BelongsToUser = true1032 p.DataTypes[i].RestrictedToUser = true1033 }1034 expected := `1035package main1036import ()1037func main() {1038 exampleFunction(ctx, exampleThing.ID, exampleAnotherThing.ID, exampleYetAnotherThing.ID)1039}1040`1041 actual := renderCallArgsToString(t, p.LastDataType().buildGetSomethingArgsWithExampleVariables(p, true))1042 assert.Equal(t, expected, actual)1043 })1044}1045func TestDataType_BuildHTTPClientRetrievalTestCallArgs(T *testing.T) {1046 T.Parallel()1047 T.Run("obligatory", func(t *testing.T) {1048 t.Parallel()1049 dt := DataType{1050 Name: wordsmith.FromSingularPascalCase("Thing"),1051 }1052 p := buildExampleTodoListProject()1053 expected := `1054package main1055import ()1056func main() {1057 exampleFunction(ctx, exampleThing.ID)1058}1059`1060 actual := renderCallArgsToString(t, dt.BuildHTTPClientRetrievalTestCallArgs(p))1061 assert.Equal(t, expected, actual)1062 })1063}1064func TestDataType_buildSingleInstanceQueryTestCallArgs(T *testing.T) {1065 T.Parallel()1066 T.Run("obligatory", func(t *testing.T) {1067 t.Parallel()1068 dt := DataType{1069 Name: wordsmith.FromSingularPascalCase("Thing"),1070 }1071 p := buildExampleTodoListProject()1072 expected := `1073package main1074import ()1075func main() {1076 exampleFunction(exampleThing.ID)1077}1078`1079 actual := renderCallArgsToString(t, dt.buildSingleInstanceQueryTestCallArgs(p))1080 assert.Equal(t, expected, actual)1081 })1082 T.Run("with multiple ownership", func(t *testing.T) {1083 t.Parallel()1084 p := buildExampleTodoListProject()1085 p.DataTypes = BuildOwnershipChain("Thing", "AnotherThing", "YetAnotherThing")1086 for i := range p.DataTypes {1087 p.DataTypes[i].BelongsToUser = true1088 p.DataTypes[i].RestrictedToUser = true1089 }1090 expected := `1091package main1092import ()1093func main() {1094 exampleFunction(exampleThing.ID, exampleAnotherThing.ID, exampleYetAnotherThing.ID, exampleYetAnotherThing.BelongsToUser)1095}1096`1097 actual := renderCallArgsToString(t, p.LastDataType().buildSingleInstanceQueryTestCallArgs(p))1098 assert.Equal(t, expected, actual)1099 })1100}1101func TestDataType_buildArgsForMethodThatHandlesAnInstanceWithStructsAndUser(T *testing.T) {1102 T.Parallel()1103 T.Run("obligatory", func(t *testing.T) {1104 t.Parallel()1105 dt := DataType{1106 Name: wordsmith.FromSingularPascalCase("Thing"),1107 }1108 p := buildExampleTodoListProject()1109 expected := `1110package main1111import ()1112func main() {1113 exampleFunction(ctx, exampleThing.ID)1114}1115`1116 actual := renderCallArgsToString(t, dt.buildArgsForMethodThatHandlesAnInstanceWithStructsAndUser(p))1117 assert.Equal(t, expected, actual)1118 })1119 T.Run("with multiple ownership", func(t *testing.T) {1120 t.Parallel()1121 p := buildExampleTodoListProject()1122 p.DataTypes = BuildOwnershipChain("Thing", "AnotherThing", "YetAnotherThing")1123 for i := range p.DataTypes {1124 p.DataTypes[i].BelongsToUser = true1125 p.DataTypes[i].RestrictedToUser = true1126 }1127 expected := `1128package main1129import ()1130func main() {1131 exampleFunction(ctx, exampleThing.ID, exampleAnotherThing.ID, exampleYetAnotherThing.ID, exampleUser.ID)1132}1133`1134 actual := renderCallArgsToString(t, p.LastDataType().buildArgsForMethodThatHandlesAnInstanceWithStructsAndUser(p))1135 assert.Equal(t, expected, actual)1136 })1137}1138func TestDataType_BuildArgsForDBQuerierExistenceMethodTest(T *testing.T) {1139 T.Parallel()1140 T.Run("obligatory", func(t *testing.T) {1141 t.Parallel()1142 dt := DataType{1143 Name: wordsmith.FromSingularPascalCase("Thing"),1144 }1145 p := buildExampleTodoListProject()1146 expected := `1147package main1148import ()1149func main() {1150 exampleFunction(ctx, exampleThing.ID)1151}1152`1153 actual := renderCallArgsToString(t, dt.BuildArgsForDBQuerierExistenceMethodTest(p))1154 assert.Equal(t, expected, actual)1155 })1156}1157func TestDataType_BuildArgsForDBQuerierRetrievalMethodTest(T *testing.T) {1158 T.Parallel()1159 T.Run("obligatory", func(t *testing.T) {1160 t.Parallel()1161 dt := DataType{1162 Name: wordsmith.FromSingularPascalCase("Thing"),1163 }1164 p := buildExampleTodoListProject()1165 expected := `1166package main1167import ()1168func main() {1169 exampleFunction(ctx, exampleThing.ID)1170}1171`1172 actual := renderCallArgsToString(t, dt.BuildArgsForDBQuerierRetrievalMethodTest(p))1173 assert.Equal(t, expected, actual)1174 })1175}1176func TestDataType_BuildArgsForServiceRouteExistenceCheck(T *testing.T) {1177 T.Parallel()1178 T.Run("obligatory", func(t *testing.T) {1179 t.Parallel()1180 dt := DataType{1181 Name: wordsmith.FromSingularPascalCase("Thing"),1182 }1183 p := buildExampleTodoListProject()1184 expected := `1185package main1186import ()1187func main() {1188 exampleFunction(ctx, thingID)1189}1190`1191 actual := renderCallArgsToString(t, dt.BuildArgsForServiceRouteExistenceCheck(p))1192 assert.Equal(t, expected, actual)1193 })1194 T.Run("obligatory", func(t *testing.T) {1195 t.Parallel()1196 p := buildExampleTodoListProject()1197 p.DataTypes = BuildOwnershipChain("Thing", "AnotherThing", "YetAnotherThing")1198 for i := range p.DataTypes {1199 p.DataTypes[i].BelongsToUser = true1200 p.DataTypes[i].RestrictedToUser = true1201 }1202 expected := `1203package main1204import ()1205func main() {1206 exampleFunction(ctx, thingID, anotherThingID, yetAnotherThingID, userID)1207}1208`1209 actual := renderCallArgsToString(t, p.LastDataType().BuildArgsForServiceRouteExistenceCheck(p))1210 assert.Equal(t, expected, actual)1211 })1212}1213func TestDataType_buildSingleInstanceQueryTestCallArgsWithoutOwnerVar(T *testing.T) {1214 T.Parallel()1215 T.Run("obligatory", func(t *testing.T) {1216 t.Parallel()1217 dt := DataType{1218 Name: wordsmith.FromSingularPascalCase("Thing"),1219 }1220 p := buildExampleTodoListProject()1221 expected := `1222package main1223import ()1224func main() {1225 exampleFunction(exampleThing.ID)1226}1227`1228 actual := renderCallArgsToString(t, dt.buildSingleInstanceQueryTestCallArgsWithoutOwnerVar(p))1229 assert.Equal(t, expected, actual)1230 })1231 T.Run("with multiple ownership", func(t *testing.T) {1232 t.Parallel()1233 p := buildExampleTodoListProject()1234 p.DataTypes = BuildOwnershipChain("Thing", "AnotherThing", "YetAnotherThing")1235 for i := range p.DataTypes {1236 p.DataTypes[i].BelongsToUser = true1237 p.DataTypes[i].RestrictedToUser = true1238 }1239 expected := `1240package main1241import ()1242func main() {1243 exampleFunction(exampleThing.ID, exampleAnotherThing.ID, exampleYetAnotherThing.ID, exampleUser.ID)1244}1245`1246 actual := renderCallArgsToString(t, p.LastDataType().buildSingleInstanceQueryTestCallArgsWithoutOwnerVar(p))1247 assert.Equal(t, expected, actual)1248 })1249}1250func TestDataType_BuildDBQuerierBuildSomethingExistsQueryTestCallArgs(T *testing.T) {1251 T.Parallel()1252 T.Run("obligatory", func(t *testing.T) {1253 t.Parallel()1254 dt := DataType{1255 Name: wordsmith.FromSingularPascalCase("Thing"),1256 }1257 p := buildExampleTodoListProject()1258 expected := `1259package main1260import ()1261func main() {1262 exampleFunction(exampleThing.ID)1263}1264`1265 actual := renderCallArgsToString(t, dt.BuildDBQuerierBuildSomethingExistsQueryTestCallArgs(p))1266 assert.Equal(t, expected, actual)1267 })1268 T.Run("with forums", func(t *testing.T) {1269 t.Parallel()1270 p := buildExampleForumsListProject()1271 dt := p.DataTypes[3]1272 expected := `1273package main1274import ()1275func main() {1276 exampleFunction(exampleForum.ID, exampleSubforum.ID, exampleThread.ID, examplePost.ID)1277}1278`1279 actual := renderCallArgsToString(t, dt.BuildDBQuerierBuildSomethingExistsQueryTestCallArgs(p))1280 assert.Equal(t, expected, actual)1281 })1282}1283func TestDataType_BuildDBQuerierRetrievalQueryTestCallArgs(T *testing.T) {1284 T.Parallel()1285 T.Run("obligatory", func(t *testing.T) {1286 t.Parallel()1287 dt := DataType{1288 Name: wordsmith.FromSingularPascalCase("Thing"),1289 }1290 p := buildExampleTodoListProject()1291 expected := `1292package main1293import ()1294func main() {1295 exampleFunction(exampleThing.ID)1296}1297`1298 actual := renderCallArgsToString(t, dt.BuildDBQuerierRetrievalQueryTestCallArgs(p))1299 assert.Equal(t, expected, actual)1300 })1301}1302func TestDataType_BuildDBQuerierSomethingExistsQueryBuilderTestPreQueryLines(T *testing.T) {1303 T.Parallel()1304 T.Run("obligatory", func(t *testing.T) {1305 t.Parallel()1306 dt := DataType{1307 Name: wordsmith.FromSingularPascalCase("Thing"),1308 }1309 p := buildExampleTodoListProject()1310 expected := `1311package main1312import (1313 fake "gitlab.com/verygoodsoftwarenotvirus/example/models/v1/fake"1314)1315func main() {1316 exampleThing := fake.BuildFakeThing()1317}1318`1319 actual := renderVariableDeclarationsToString(t, dt.BuildDBQuerierSomethingExistsQueryBuilderTestPreQueryLines(p))1320 assert.Equal(t, expected, actual)1321 })1322}1323func TestDataType_BuildDBQuerierGetSomethingQueryBuilderTestPreQueryLines(T *testing.T) {1324 T.Parallel()1325 T.Run("obligatory", func(t *testing.T) {1326 t.Parallel()1327 dt := DataType{1328 Name: wordsmith.FromSingularPascalCase("Thing"),1329 }1330 p := buildExampleTodoListProject()1331 expected := `1332package main1333import (1334 fake "gitlab.com/verygoodsoftwarenotvirus/example/models/v1/fake"1335)1336func main() {1337 exampleThing := fake.BuildFakeThing()1338}1339`1340 actual := renderVariableDeclarationsToString(t, dt.BuildDBQuerierGetSomethingQueryBuilderTestPreQueryLines(p))1341 assert.Equal(t, expected, actual)1342 })1343}1344func TestDataType_BuildDBQuerierGetListOfSomethingQueryBuilderTestPreQueryLines(T *testing.T) {1345 T.Parallel()1346 T.Run("obligatory", func(t *testing.T) {1347 t.Parallel()1348 dt := DataType{1349 Name: wordsmith.FromSingularPascalCase("Thing"),1350 }1351 p := buildExampleTodoListProject()1352 expected := `1353package main1354import (1355 fake "gitlab.com/verygoodsoftwarenotvirus/example/models/v1/fake"1356)1357func main() {1358 filter := fake.BuildFleshedOutQueryFilter()1359}1360`1361 actual := renderVariableDeclarationsToString(t, dt.BuildDBQuerierGetListOfSomethingQueryBuilderTestPreQueryLines(p))1362 assert.Equal(t, expected, actual)1363 })1364 T.Run("with multiple ownership", func(t *testing.T) {1365 t.Parallel()1366 p := buildExampleTodoListProject()1367 p.DataTypes = BuildOwnershipChain("Thing", "AnotherThing", "YetAnotherThing")1368 for i := range p.DataTypes {1369 p.DataTypes[i].BelongsToUser = true1370 p.DataTypes[i].RestrictedToUser = true1371 }1372 expected := `1373package main1374import (1375 fake "gitlab.com/verygoodsoftwarenotvirus/example/models/v1/fake"1376)1377func main() {1378 exampleUser := fake.BuildFakeUser()1379 exampleThing := fake.BuildFakeThing()1380 exampleThing.BelongsToUser = exampleUser.ID1381 exampleAnotherThing := fake.BuildFakeAnotherThing()1382 exampleAnotherThing.BelongsToUser = exampleUser.ID1383 exampleAnotherThing.BelongsToThing = exampleThing.ID1384 filter := fake.BuildFleshedOutQueryFilter()1385}1386`1387 actual := renderVariableDeclarationsToString(t, p.LastDataType().BuildDBQuerierGetListOfSomethingQueryBuilderTestPreQueryLines(p))1388 assert.Equal(t, expected, actual)1389 })1390}1391func TestDataType_BuildDBQuerierCreateSomethingQueryBuilderTestPreQueryLines(T *testing.T) {1392 T.Parallel()1393 T.Run("obligatory", func(t *testing.T) {1394 t.Parallel()1395 dt := DataType{1396 Name: wordsmith.FromSingularPascalCase("Thing"),1397 }1398 p := buildExampleTodoListProject()1399 expected := `1400package main1401import (1402 fake "gitlab.com/verygoodsoftwarenotvirus/example/models/v1/fake"1403)1404func main() {1405 exampleThing := fake.BuildFakeThing()1406}1407`1408 actual := renderVariableDeclarationsToString(t, dt.BuildDBQuerierCreateSomethingQueryBuilderTestPreQueryLines(p))1409 assert.Equal(t, expected, actual)1410 })1411}1412func TestDataType_BuildDBQuerierUpdateSomethingQueryBuilderTestPreQueryLines(T *testing.T) {1413 T.Parallel()1414 T.Run("obligatory", func(t *testing.T) {1415 t.Parallel()1416 dt := DataType{1417 Name: wordsmith.FromSingularPascalCase("Thing"),1418 }1419 p := buildExampleTodoListProject()1420 expected := `1421package main1422import (1423 fake "gitlab.com/verygoodsoftwarenotvirus/example/models/v1/fake"1424)1425func main() {1426 exampleThing := fake.BuildFakeThing()1427}1428`1429 actual := renderVariableDeclarationsToString(t, dt.BuildDBQuerierUpdateSomethingQueryBuilderTestPreQueryLines(p))1430 assert.Equal(t, expected, actual)1431 })1432}1433func TestDataType_BuildDBQuerierUpdateSomethingTestPrerequisiteVariables(T *testing.T) {1434 T.Parallel()1435 T.Run("obligatory", func(t *testing.T) {1436 t.Parallel()1437 dt := DataType{1438 Name: wordsmith.FromSingularPascalCase("Thing"),1439 }1440 p := buildExampleTodoListProject()1441 expected := `1442package main1443import (1444 fake "gitlab.com/verygoodsoftwarenotvirus/example/models/v1/fake"1445)1446func main() {1447 exampleThing := fake.BuildFakeThing()1448}1449`1450 actual := renderVariableDeclarationsToString(t, dt.BuildDBQuerierUpdateSomethingTestPrerequisiteVariables(p))1451 assert.Equal(t, expected, actual)1452 })1453}1454func TestDataType_BuildDBQuerierArchiveSomethingTestPrerequisiteVariables(T *testing.T) {1455 T.Parallel()1456 T.Run("obligatory", func(t *testing.T) {1457 t.Parallel()1458 dt := DataType{1459 Name: wordsmith.FromSingularPascalCase("Thing"),1460 }1461 p := buildExampleTodoListProject()1462 expected := `1463package main1464import (1465 fake "gitlab.com/verygoodsoftwarenotvirus/example/models/v1/fake"1466)1467func main() {1468 exampleThing := fake.BuildFakeThing()1469}1470`1471 actual := renderVariableDeclarationsToString(t, dt.BuildDBQuerierArchiveSomethingTestPrerequisiteVariables(p))1472 assert.Equal(t, expected, actual)1473 })1474}1475func TestDataType_BuildDBQuerierArchiveSomethingQueryBuilderTestPreQueryLines(T *testing.T) {1476 T.Parallel()1477 T.Run("obligatory", func(t *testing.T) {1478 t.Parallel()1479 dt := DataType{1480 Name: wordsmith.FromSingularPascalCase("Thing"),1481 }1482 p := buildExampleTodoListProject()1483 expected := `1484package main1485import (1486 fake "gitlab.com/verygoodsoftwarenotvirus/example/models/v1/fake"1487)1488func main() {1489 exampleThing := fake.BuildFakeThing()1490}1491`1492 actual := renderVariableDeclarationsToString(t, dt.BuildDBQuerierArchiveSomethingQueryBuilderTestPreQueryLines(p))1493 assert.Equal(t, expected, actual)1494 })1495}1496func TestDataType_BuildGetSomethingLogValues(T *testing.T) {1497 T.Parallel()1498 T.Run("obligatory", func(t *testing.T) {1499 t.Parallel()1500 dt := DataType{1501 Name: wordsmith.FromSingularPascalCase("Thing"),1502 }1503 p := buildExampleTodoListProject()1504 expected := `1505package main1506import ()1507func main() {1508 map[string]interface{}{1509 "thing_id": thingID,1510 }1511}1512`1513 actual := renderIndependentStatementToString(t, dt.BuildGetSomethingLogValues(p))1514 assert.Equal(t, expected, actual)1515 })1516 T.Run("with multiple ownership", func(t *testing.T) {1517 t.Parallel()1518 p := buildExampleTodoListProject()1519 p.DataTypes = BuildOwnershipChain("Thing", "AnotherThing", "YetAnotherThing")1520 for i := range p.DataTypes {1521 p.DataTypes[i].BelongsToUser = true1522 p.DataTypes[i].RestrictedToUser = true1523 }1524 expected := `1525package main1526import ()1527func main() {1528 map[string]interface{}{1529 "thing_id": thingID,1530 "another_thing_id": anotherThingID,1531 "yet_another_thing_id": yetAnotherThingID,1532 "user_id": userID,1533 }1534}1535`1536 actual := renderIndependentStatementToString(t, p.LastDataType().BuildGetSomethingLogValues(p))1537 assert.Equal(t, expected, actual)1538 })1539}1540func TestDataType_BuildGetListOfSomethingLogValues(T *testing.T) {1541 T.Parallel()1542 T.Run("obligatory", func(t *testing.T) {1543 t.Parallel()1544 p := buildExampleTodoListProject()1545 p.DataTypes = BuildOwnershipChain("Thing", "AnotherThing", "YetAnotherThing")1546 expected := `1547package main1548import ()1549func main() {1550 map[string]interface{}{1551 "thing_id": thingID,1552 "another_thing_id": anotherThingID,1553 }1554}1555`1556 actual := renderIndependentStatementToString(t, p.LastDataType().BuildGetListOfSomethingLogValues(p))1557 assert.Equal(t, expected, actual)1558 })1559 T.Run("with multiple ownership", func(t *testing.T) {1560 t.Parallel()1561 p := buildExampleTodoListProject()1562 p.DataTypes = BuildOwnershipChain("Thing", "AnotherThing", "YetAnotherThing")1563 for i := range p.DataTypes {1564 p.DataTypes[i].BelongsToUser = true1565 p.DataTypes[i].RestrictedToUser = true1566 }1567 expected := `1568package main1569import ()1570func main() {1571 map[string]interface{}{1572 "thing_id": thingID,1573 "another_thing_id": anotherThingID,1574 "user_id": userID,1575 }1576}1577`1578 actual := renderIndependentStatementToString(t, p.LastDataType().BuildGetListOfSomethingLogValues(p))1579 assert.Equal(t, expected, actual)1580 })1581}1582func TestDataType_buildGetListOfSomethingParams(T *testing.T) {1583 T.Parallel()1584 T.Run("simple being models package", func(t *testing.T) {1585 t.Parallel()1586 dt := DataType{1587 Name: wordsmith.FromSingularPascalCase("Thing"),1588 }1589 p := buildExampleTodoListProject()1590 expected := `1591package main1592import (1593 "context"1594)1595func example(ctx context.Context, filter *QueryFilter) {}1596`1597 actual := renderFunctionParamsToString(t, dt.buildGetListOfSomethingParams(p, true))1598 assert.Equal(t, expected, actual)1599 })1600 T.Run("without being models package", func(t *testing.T) {1601 t.Parallel()1602 dt := DataType{1603 Name: wordsmith.FromSingularPascalCase("Thing"),1604 }1605 p := buildExampleTodoListProject()1606 expected := `1607package main1608import (1609 "context"1610 v1 "gitlab.com/verygoodsoftwarenotvirus/example/models/v1"1611)1612func example(ctx context.Context, filter *v1.QueryFilter) {}1613`1614 actual := renderFunctionParamsToString(t, dt.buildGetListOfSomethingParams(p, false))1615 assert.Equal(t, expected, actual)1616 })1617 T.Run("with multiple ownership", func(t *testing.T) {1618 t.Parallel()1619 p := buildExampleTodoListProject()1620 p.DataTypes = BuildOwnershipChain("Thing", "AnotherThing", "YetAnotherThing")1621 for i := range p.DataTypes {1622 p.DataTypes[i].BelongsToUser = true1623 p.DataTypes[i].RestrictedToUser = true1624 }1625 expected := `1626package main1627import (1628 "context"1629)1630func example(ctx context.Context, thingID, anotherThingID, userID uint64, filter *QueryFilter) {}1631`1632 actual := renderFunctionParamsToString(t, p.LastDataType().buildGetListOfSomethingParams(p, true))1633 assert.Equal(t, expected, actual)1634 })1635}1636func TestDataType_BuildMockDataManagerListRetrievalMethodParams(T *testing.T) {1637 T.Parallel()1638 T.Run("simple", func(t *testing.T) {1639 t.Parallel()1640 dt := DataType{1641 Name: wordsmith.FromSingularPascalCase("Thing"),1642 }1643 p := buildExampleTodoListProject()1644 expected := `1645package main1646import (1647 "context"1648 v1 "gitlab.com/verygoodsoftwarenotvirus/example/models/v1"1649)1650func example(ctx context.Context, filter *v1.QueryFilter) {}1651`1652 actual := renderFunctionParamsToString(t, dt.BuildMockDataManagerListRetrievalMethodParams(p))1653 assert.Equal(t, expected, actual)1654 })1655}1656func TestDataType_BuildInterfaceDefinitionListRetrievalMethodParams(T *testing.T) {1657 T.Parallel()1658 T.Run("simple", func(t *testing.T) {1659 t.Parallel()1660 dt := DataType{1661 Name: wordsmith.FromSingularPascalCase("Thing"),1662 }1663 p := buildExampleTodoListProject()1664 expected := `1665package main1666import (1667 "context"1668)1669func example(ctx context.Context, filter *QueryFilter) {}1670`1671 actual := renderFunctionParamsToString(t, dt.BuildInterfaceDefinitionListRetrievalMethodParams(p))1672 assert.Equal(t, expected, actual)1673 })1674}1675func TestDataType_BuildDBClientListRetrievalMethodParams(T *testing.T) {1676 T.Parallel()1677 T.Run("simple", func(t *testing.T) {1678 t.Parallel()1679 dt := DataType{1680 Name: wordsmith.FromSingularPascalCase("Thing"),1681 }1682 p := buildExampleTodoListProject()1683 expected := `1684package main1685import (1686 "context"1687 v1 "gitlab.com/verygoodsoftwarenotvirus/example/models/v1"1688)1689func example(ctx context.Context, filter *v1.QueryFilter) {}1690`1691 actual := renderFunctionParamsToString(t, dt.BuildDBClientListRetrievalMethodParams(p))1692 assert.Equal(t, expected, actual)1693 })1694}1695func TestDataType_BuildDBQuerierListRetrievalMethodParams(T *testing.T) {1696 T.Parallel()1697 T.Run("simple", func(t *testing.T) {1698 t.Parallel()1699 dt := DataType{1700 Name: wordsmith.FromSingularPascalCase("Thing"),1701 }1702 p := buildExampleTodoListProject()1703 expected := `1704package main1705import (1706 "context"1707 v1 "gitlab.com/verygoodsoftwarenotvirus/example/models/v1"1708)1709func example(ctx context.Context, filter *v1.QueryFilter) {}1710`1711 actual := renderFunctionParamsToString(t, dt.BuildDBQuerierListRetrievalMethodParams(p))1712 assert.Equal(t, expected, actual)1713 })1714}1715func TestDataType_BuildDBQuerierListRetrievalQueryBuildingMethodParams(T *testing.T) {1716 T.Parallel()1717 T.Run("simple", func(t *testing.T) {1718 t.Parallel()1719 dt := DataType{1720 Name: wordsmith.FromSingularPascalCase("Thing"),1721 }1722 p := buildExampleTodoListProject()1723 expected := `1724package main1725import (1726 v1 "gitlab.com/verygoodsoftwarenotvirus/example/models/v1"1727)1728func example(filter *v1.QueryFilter) {}1729`1730 actual := renderFunctionParamsToString(t, dt.BuildDBQuerierListRetrievalQueryBuildingMethodParams(p))1731 assert.Equal(t, expected, actual)1732 })1733}1734func TestDataType_buildCreateSomethingParams(T *testing.T) {1735 T.Parallel()1736 T.Run("simple being models package", func(t *testing.T) {1737 t.Parallel()1738 dt := DataType{1739 Name: wordsmith.FromSingularPascalCase("Thing"),1740 }1741 p := buildExampleTodoListProject()1742 expected := `1743package main1744import (1745 "context"1746)1747func example(ctx context.Context, input *ThingCreationInput) {}1748`1749 actual := renderFunctionParamsToString(t, dt.buildCreateSomethingParams(p, true))1750 assert.Equal(t, expected, actual)1751 })1752 T.Run("without being models package", func(t *testing.T) {1753 t.Parallel()1754 dt := DataType{1755 Name: wordsmith.FromSingularPascalCase("Thing"),1756 }1757 p := buildExampleTodoListProject()1758 expected := `1759package main1760import (1761 "context"1762 v1 "gitlab.com/verygoodsoftwarenotvirus/example/models/v1"1763)1764func example(ctx context.Context, input *v1.ThingCreationInput) {}1765`1766 actual := renderFunctionParamsToString(t, dt.buildCreateSomethingParams(p, false))1767 assert.Equal(t, expected, actual)1768 })1769}1770func TestDataType_BuildMockInterfaceDefinitionCreationMethodParams(T *testing.T) {1771 T.Parallel()1772 T.Run("simple", func(t *testing.T) {1773 t.Parallel()1774 dt := DataType{1775 Name: wordsmith.FromSingularPascalCase("Thing"),1776 }1777 p := buildExampleTodoListProject()1778 expected := `1779package main1780import (1781 "context"1782 v1 "gitlab.com/verygoodsoftwarenotvirus/example/models/v1"1783)1784func example(ctx context.Context, input *v1.ThingCreationInput) {}1785`1786 actual := renderFunctionParamsToString(t, dt.BuildMockInterfaceDefinitionCreationMethodParams(p))1787 assert.Equal(t, expected, actual)1788 })1789}1790func TestDataType_BuildInterfaceDefinitionCreationMethodParams(T *testing.T) {1791 T.Parallel()1792 T.Run("simple", func(t *testing.T) {1793 t.Parallel()1794 dt := DataType{1795 Name: wordsmith.FromSingularPascalCase("Thing"),1796 }1797 p := buildExampleTodoListProject()1798 expected := `1799package main1800import (1801 "context"1802)1803func example(ctx context.Context, input *ThingCreationInput) {}1804`1805 actual := renderFunctionParamsToString(t, dt.BuildInterfaceDefinitionCreationMethodParams(p))1806 assert.Equal(t, expected, actual)1807 })1808}1809func TestDataType_BuildDBClientCreationMethodParams(T *testing.T) {1810 T.Parallel()1811 T.Run("simple", func(t *testing.T) {1812 t.Parallel()1813 dt := DataType{1814 Name: wordsmith.FromSingularPascalCase("Thing"),1815 }1816 p := buildExampleTodoListProject()1817 expected := `1818package main1819import (1820 "context"1821 v1 "gitlab.com/verygoodsoftwarenotvirus/example/models/v1"1822)1823func example(ctx context.Context, input *v1.ThingCreationInput) {}1824`1825 actual := renderFunctionParamsToString(t, dt.BuildDBClientCreationMethodParams(p))1826 assert.Equal(t, expected, actual)1827 })1828}1829func TestDataType_BuildDBQuerierCreationMethodParams(T *testing.T) {1830 T.Parallel()1831 T.Run("simple", func(t *testing.T) {1832 t.Parallel()1833 dt := DataType{1834 Name: wordsmith.FromSingularPascalCase("Thing"),1835 }1836 p := buildExampleTodoListProject()1837 expected := `1838package main1839import (1840 "context"1841 v1 "gitlab.com/verygoodsoftwarenotvirus/example/models/v1"1842)1843func example(ctx context.Context, input *v1.ThingCreationInput) {}1844`1845 actual := renderFunctionParamsToString(t, dt.BuildDBQuerierCreationMethodParams(p))1846 assert.Equal(t, expected, actual)1847 })1848}1849func TestDataType_BuildDBQuerierCreationQueryBuildingMethodParams(T *testing.T) {1850 T.Parallel()1851 T.Run("simple being models package", func(t *testing.T) {1852 t.Parallel()1853 dt := DataType{1854 Name: wordsmith.FromSingularPascalCase("Thing"),1855 }1856 p := buildExampleTodoListProject()1857 expected := `1858package main1859import (1860 "context"1861)1862func example(ctx context.Context, input *Thing) {}1863`1864 actual := renderFunctionParamsToString(t, dt.BuildDBQuerierCreationQueryBuildingMethodParams(p, true))1865 assert.Equal(t, expected, actual)1866 })1867 T.Run("without being models package", func(t *testing.T) {1868 t.Parallel()1869 dt := DataType{1870 Name: wordsmith.FromSingularPascalCase("Thing"),1871 }1872 p := buildExampleTodoListProject()1873 expected := `1874package main1875import (1876 "context"1877 v1 "gitlab.com/verygoodsoftwarenotvirus/example/models/v1"1878)1879func example(ctx context.Context, input *v1.Thing) {}1880`1881 actual := renderFunctionParamsToString(t, dt.BuildDBQuerierCreationQueryBuildingMethodParams(p, false))1882 assert.Equal(t, expected, actual)1883 })1884}1885func TestDataType_buildCreateSomethingArgs(T *testing.T) {1886 T.Parallel()1887 T.Run("obligatory", func(t *testing.T) {1888 t.Parallel()1889 dt := DataType{1890 Name: wordsmith.FromSingularPascalCase("Thing"),1891 }1892 expected := `1893package main1894import ()1895func main() {1896 exampleFunction(ctx, input)1897}1898`1899 actual := renderCallArgsToString(t, dt.buildCreateSomethingArgs())1900 assert.Equal(t, expected, actual)1901 })1902}1903func TestDataType_BuildMockInterfaceDefinitionCreationMethodCallArgs(T *testing.T) {1904 T.Parallel()1905 T.Run("obligatory", func(t *testing.T) {1906 t.Parallel()1907 dt := DataType{1908 Name: wordsmith.FromSingularPascalCase("Thing"),1909 }1910 expected := `1911package main1912import ()1913func main() {1914 exampleFunction(ctx, input)1915}1916`1917 actual := renderCallArgsToString(t, dt.BuildMockInterfaceDefinitionCreationMethodCallArgs())1918 assert.Equal(t, expected, actual)1919 })1920}1921func TestDataType_BuildDBQuerierCreationMethodQueryBuildingArgs(T *testing.T) {1922 T.Parallel()1923 T.Run("obligatory", func(t *testing.T) {1924 t.Parallel()1925 dt := DataType{1926 Name: wordsmith.FromSingularPascalCase("Thing"),1927 }1928 expected := `1929package main1930import ()1931func main() {1932 exampleFunction(input)1933}1934`1935 actual := renderCallArgsToString(t, dt.BuildDBQuerierCreationMethodQueryBuildingArgs())1936 assert.Equal(t, expected, actual)1937 })1938}1939func TestDataType_BuildArgsForDBQuerierTestOfListRetrievalQueryBuilder(T *testing.T) {1940 T.Parallel()1941 T.Run("obligatory", func(t *testing.T) {1942 t.Parallel()1943 dt := DataType{1944 Name: wordsmith.FromSingularPascalCase("Thing"),1945 }1946 p := buildExampleTodoListProject()1947 expected := `1948package main1949import ()1950func main() {1951 exampleFunction(filter)1952}1953`1954 actual := renderCallArgsToString(t, dt.BuildArgsForDBQuerierTestOfListRetrievalQueryBuilder(p))1955 assert.Equal(t, expected, actual)1956 })1957 T.Run("with multiple ownership", func(t *testing.T) {1958 t.Parallel()1959 p := buildExampleTodoListProject()1960 p.DataTypes = BuildOwnershipChain("Thing", "AnotherThing", "YetAnotherThing")1961 for i := range p.DataTypes {1962 p.DataTypes[i].BelongsToUser = true1963 p.DataTypes[i].RestrictedToUser = true1964 }1965 expected := `1966package main1967import ()1968func main() {1969 exampleFunction(exampleThing.ID, exampleAnotherThing.ID, exampleUser.ID, filter)1970}1971`1972 actual := renderCallArgsToString(t, p.LastDataType().BuildArgsForDBQuerierTestOfListRetrievalQueryBuilder(p))1973 assert.Equal(t, expected, actual)1974 })1975}1976func TestDataType_BuildArgsForDBQuerierTestOfUpdateQueryBuilder(T *testing.T) {1977 T.Parallel()1978 T.Run("obligatory", func(t *testing.T) {1979 t.Parallel()1980 dt := DataType{1981 Name: wordsmith.FromSingularPascalCase("Thing"),1982 }1983 expected := `1984package main1985import ()1986func main() {1987 exampleFunction(exampleThing)1988}1989`1990 actual := renderCallArgsToString(t, dt.BuildArgsForDBQuerierTestOfUpdateQueryBuilder())1991 assert.Equal(t, expected, actual)1992 })1993}1994func TestDataType_BuildArgsForDBQuerierTestOfArchiveQueryBuilder(T *testing.T) {1995 T.Parallel()1996 T.Run("obligatory", func(t *testing.T) {1997 t.Parallel()1998 dt := DataType{1999 Name: wordsmith.FromSingularPascalCase("Thing"),2000 }2001 expected := `2002package main2003import ()2004func main() {2005 exampleFunction(exampleThing.ID)2006}2007`2008 actual := renderCallArgsToString(t, dt.BuildArgsForDBQuerierTestOfArchiveQueryBuilder())2009 assert.Equal(t, expected, actual)2010 })2011 T.Run("with multiple ownership", func(t *testing.T) {2012 t.Parallel()2013 dt := DataType{2014 BelongsToStruct: wordsmith.FromSingularPascalCase("Thing"),2015 Name: wordsmith.FromSingularPascalCase("AnotherThing"),2016 BelongsToUser: true,2017 }2018 expected := `2019package main2020import ()2021func main() {2022 exampleFunction(exampleThing.ID, exampleAnotherThing.ID, exampleUser.ID)2023}2024`2025 actual := renderCallArgsToString(t, dt.BuildArgsForDBQuerierTestOfArchiveQueryBuilder())2026 assert.Equal(t, expected, actual)2027 })2028}2029func TestDataType_BuildArgsForDBQuerierTestOfUpdateMethod(T *testing.T) {2030 T.Parallel()2031 T.Run("obligatory", func(t *testing.T) {2032 t.Parallel()2033 dt := DataType{2034 Name: wordsmith.FromSingularPascalCase("Thing"),2035 }2036 expected := `2037package main2038import ()2039func main() {2040 exampleFunction(ctx, exampleThing)2041}2042`2043 actual := renderCallArgsToString(t, dt.BuildArgsForDBQuerierTestOfUpdateMethod())2044 assert.Equal(t, expected, actual)2045 })2046}2047func TestDataType_BuildDBQuerierCreationMethodArgsToUseFromMethodTest(T *testing.T) {2048 T.Parallel()2049 T.Run("obligatory", func(t *testing.T) {2050 t.Parallel()2051 dt := DataType{2052 Name: wordsmith.FromSingularPascalCase("Thing"),2053 }2054 expected := `2055package main2056import ()2057func main() {2058 exampleFunction(ctx, exampleInput)2059}2060`2061 actual := renderCallArgsToString(t, dt.BuildDBQuerierCreationMethodArgsToUseFromMethodTest())2062 assert.Equal(t, expected, actual)2063 })2064}2065func TestDataType_BuildArgsToUseForDBQuerierCreationQueryBuildingTest(T *testing.T) {2066 T.Parallel()2067 T.Run("obligatory", func(t *testing.T) {2068 t.Parallel()2069 dt := DataType{2070 Name: wordsmith.FromSingularPascalCase("Thing"),2071 }2072 expected := `2073package main2074import ()2075func main() {2076 exampleFunction(exampleThing)2077}2078`2079 actual := renderCallArgsToString(t, dt.BuildArgsToUseForDBQuerierCreationQueryBuildingTest())2080 assert.Equal(t, expected, actual)2081 })2082}2083func TestDataType_BuildDBClientCreationMethodCallArgs(T *testing.T) {2084 T.Parallel()2085 T.Run("obligatory", func(t *testing.T) {2086 t.Parallel()2087 dt := DataType{2088 Name: wordsmith.FromSingularPascalCase("Thing"),2089 }2090 expected := `2091package main2092import ()2093func main() {2094 exampleFunction(ctx, input)2095}2096`2097 actual := renderCallArgsToString(t, dt.BuildDBClientCreationMethodCallArgs())2098 assert.Equal(t, expected, actual)2099 })2100}2101func TestDataType_buildUpdateSomethingParams(T *testing.T) {2102 T.Parallel()2103 T.Run("simple being models package", func(t *testing.T) {2104 t.Parallel()2105 dt := DataType{2106 Name: wordsmith.FromSingularPascalCase("Thing"),2107 }2108 p := buildExampleTodoListProject()2109 expected := `2110package main2111import (2112 "context"2113)2114func example(ctx context.Context, updated *Thing) {}2115`2116 actual := renderFunctionParamsToString(t, dt.buildUpdateSomethingParams(p, "updated", true))2117 assert.Equal(t, expected, actual)2118 })2119 T.Run("while being models package", func(t *testing.T) {2120 t.Parallel()2121 dt := DataType{2122 Name: wordsmith.FromSingularPascalCase("Thing"),2123 }2124 p := buildExampleTodoListProject()2125 expected := `2126package main2127import (2128 "context"2129 v1 "gitlab.com/verygoodsoftwarenotvirus/example/models/v1"2130)2131func example(ctx context.Context, updated *v1.Thing) {}2132`2133 actual := renderFunctionParamsToString(t, dt.buildUpdateSomethingParams(p, "updated", false))2134 assert.Equal(t, expected, actual)2135 })2136 T.Run("panics with empty input", func(t *testing.T) {2137 t.Parallel()2138 p := buildExampleTodoListProject()2139 defer func() {2140 if r := recover(); r == nil {2141 t.Error("expected panic did not occur")2142 }2143 }()2144 renderFunctionParamsToString(t, p.LastDataType().buildUpdateSomethingParams(p, "", true))2145 })2146}2147func TestDataType_BuildDBClientUpdateMethodParams(T *testing.T) {2148 T.Parallel()2149 T.Run("simple", func(t *testing.T) {2150 t.Parallel()2151 dt := DataType{2152 Name: wordsmith.FromSingularPascalCase("Thing"),2153 }2154 p := buildExampleTodoListProject()2155 expected := `2156package main2157import (2158 "context"2159 v1 "gitlab.com/verygoodsoftwarenotvirus/example/models/v1"2160)2161func example(ctx context.Context, updated *v1.Thing) {}2162`2163 actual := renderFunctionParamsToString(t, dt.BuildDBClientUpdateMethodParams(p, "updated"))2164 assert.Equal(t, expected, actual)2165 })2166}2167func TestDataType_BuildDBQuerierUpdateMethodParams(T *testing.T) {2168 T.Parallel()2169 T.Run("simple", func(t *testing.T) {2170 t.Parallel()2171 dt := DataType{2172 Name: wordsmith.FromSingularPascalCase("Thing"),2173 }2174 p := buildExampleTodoListProject()2175 expected := `2176package main2177import (2178 "context"2179 v1 "gitlab.com/verygoodsoftwarenotvirus/example/models/v1"2180)2181func example(ctx context.Context, updated *v1.Thing) {}2182`2183 actual := renderFunctionParamsToString(t, dt.BuildDBQuerierUpdateMethodParams(p, "updated"))2184 assert.Equal(t, expected, actual)2185 })2186}2187func TestDataType_BuildDBQuerierUpdateQueryBuildingMethodParams(T *testing.T) {2188 T.Parallel()2189 T.Run("simple", func(t *testing.T) {2190 t.Parallel()2191 dt := DataType{2192 Name: wordsmith.FromSingularPascalCase("Thing"),2193 }2194 p := buildExampleTodoListProject()2195 expected := `2196package main2197import (2198 v1 "gitlab.com/verygoodsoftwarenotvirus/example/models/v1"2199)2200func example(updated *v1.Thing) {}2201`2202 actual := renderFunctionParamsToString(t, dt.BuildDBQuerierUpdateQueryBuildingMethodParams(p, "updated"))2203 assert.Equal(t, expected, actual)2204 })2205}2206func TestDataType_BuildInterfaceDefinitionUpdateMethodParams(T *testing.T) {2207 T.Parallel()2208 T.Run("simple", func(t *testing.T) {2209 t.Parallel()2210 dt := DataType{2211 Name: wordsmith.FromSingularPascalCase("Thing"),2212 }2213 p := buildExampleTodoListProject()2214 expected := `2215package main2216import (2217 "context"2218)2219func example(ctx context.Context, updated *Thing) {}2220`2221 actual := renderFunctionParamsToString(t, dt.BuildInterfaceDefinitionUpdateMethodParams(p, "updated"))2222 assert.Equal(t, expected, actual)2223 })2224}2225func TestDataType_BuildMockDataManagerUpdateMethodParams(T *testing.T) {2226 T.Parallel()2227 T.Run("simple", func(t *testing.T) {2228 t.Parallel()2229 dt := DataType{2230 Name: wordsmith.FromSingularPascalCase("Thing"),2231 }2232 p := buildExampleTodoListProject()2233 expected := `2234package main2235import (2236 "context"2237 v1 "gitlab.com/verygoodsoftwarenotvirus/example/models/v1"2238)2239func example(ctx context.Context, updated *v1.Thing) {}2240`2241 actual := renderFunctionParamsToString(t, dt.BuildMockDataManagerUpdateMethodParams(p, "updated"))2242 assert.Equal(t, expected, actual)2243 })2244}2245func TestDataType_buildUpdateSomethingArgsWithExampleVars(T *testing.T) {2246 T.Parallel()2247 T.Run("obligatory", func(t *testing.T) {2248 t.Parallel()2249 dt := DataType{2250 Name: wordsmith.FromSingularPascalCase("Thing"),2251 }2252 p := buildExampleTodoListProject()2253 expected := `2254package main2255import ()2256func main() {2257 exampleFunction(ctx, updated)2258}2259`2260 actual := renderCallArgsToString(t, dt.buildUpdateSomethingArgsWithExampleVars(p, "updated"))2261 assert.Equal(t, expected, actual)2262 })2263 T.Run("with multiple ownership", func(t *testing.T) {2264 t.Parallel()2265 p := buildExampleTodoListProject()2266 p.DataTypes = BuildOwnershipChain("Thing", "AnotherThing", "YetAnotherThing")2267 for i := range p.DataTypes {2268 p.DataTypes[i].BelongsToUser = true2269 p.DataTypes[i].RestrictedToUser = true2270 }2271 expected := `2272package main2273import ()2274func main() {2275 exampleFunction(ctx, Thing.ID, updated)2276}2277`2278 actual := renderCallArgsToString(t, p.LastDataType().buildUpdateSomethingArgsWithExampleVars(p, "updated"))2279 assert.Equal(t, expected, actual)2280 })2281}2282func TestDataType_buildUpdateSomethingArgs(T *testing.T) {2283 T.Parallel()2284 T.Run("obligatory", func(t *testing.T) {2285 t.Parallel()2286 dt := DataType{2287 Name: wordsmith.FromSingularPascalCase("Thing"),2288 }2289 expected := `2290package main2291import ()2292func main() {2293 exampleFunction(ctx, updated)2294}2295`2296 actual := renderCallArgsToString(t, dt.buildUpdateSomethingArgs("updated"))2297 assert.Equal(t, expected, actual)2298 })2299}2300func TestDataType_BuildDBClientUpdateMethodCallArgs(T *testing.T) {2301 T.Parallel()2302 T.Run("obligatory", func(t *testing.T) {2303 t.Parallel()2304 dt := DataType{2305 Name: wordsmith.FromSingularPascalCase("Thing"),2306 }2307 expected := `2308package main2309import ()2310func main() {2311 exampleFunction(ctx, updated)2312}2313`2314 actual := renderCallArgsToString(t, dt.BuildDBClientUpdateMethodCallArgs("updated"))2315 assert.Equal(t, expected, actual)2316 })2317}2318func TestDataType_BuildDBQuerierUpdateMethodArgs(T *testing.T) {2319 T.Parallel()2320 T.Run("obligatory", func(t *testing.T) {2321 t.Parallel()2322 dt := DataType{2323 Name: wordsmith.FromSingularPascalCase("Thing"),2324 }2325 expected := `2326package main2327import ()2328func main() {2329 exampleFunction(updated)2330}2331`2332 actual := renderCallArgsToString(t, dt.BuildDBQuerierUpdateMethodArgs("updated"))2333 assert.Equal(t, expected, actual)2334 })2335}2336func TestDataType_BuildMockDataManagerUpdateMethodCallArgs(T *testing.T) {2337 T.Parallel()2338 T.Run("obligatory", func(t *testing.T) {2339 t.Parallel()2340 dt := DataType{2341 Name: wordsmith.FromSingularPascalCase("Thing"),2342 }2343 expected := `2344package main2345import ()2346func main() {2347 exampleFunction(ctx, updated)2348}2349`2350 actual := renderCallArgsToString(t, dt.BuildMockDataManagerUpdateMethodCallArgs("updated"))2351 assert.Equal(t, expected, actual)2352 })2353}2354func TestDataType_buildGetListOfSomethingArgs(T *testing.T) {2355 T.Parallel()2356 T.Run("obligatory", func(t *testing.T) {2357 t.Parallel()2358 dt := DataType{2359 Name: wordsmith.FromSingularPascalCase("Thing"),2360 }2361 p := buildExampleTodoListProject()2362 expected := `2363package main2364import ()2365func main() {2366 exampleFunction(ctx, filter)2367}2368`2369 actual := renderCallArgsToString(t, dt.buildGetListOfSomethingArgs(p))2370 assert.Equal(t, expected, actual)2371 })2372 T.Run("with multiple ownership", func(t *testing.T) {2373 t.Parallel()2374 p := buildExampleTodoListProject()2375 p.DataTypes = BuildOwnershipChain("Thing", "AnotherThing", "YetAnotherThing")2376 for i := range p.DataTypes {2377 p.DataTypes[i].BelongsToUser = true2378 p.DataTypes[i].RestrictedToUser = true2379 }2380 expected := `2381package main2382import ()2383func main() {2384 exampleFunction(ctx, thingID, anotherThingID, userID, filter)2385}2386`2387 actual := renderCallArgsToString(t, p.LastDataType().buildGetListOfSomethingArgs(p))2388 assert.Equal(t, expected, actual)2389 })2390}2391func TestDataType_BuildDBClientListRetrievalMethodCallArgs(T *testing.T) {2392 T.Parallel()2393 T.Run("obligatory", func(t *testing.T) {2394 t.Parallel()2395 dt := DataType{2396 Name: wordsmith.FromSingularPascalCase("Thing"),2397 }2398 p := buildExampleTodoListProject()2399 expected := `2400package main2401import ()2402func main() {2403 exampleFunction(ctx, filter)2404}2405`2406 actual := renderCallArgsToString(t, dt.BuildDBClientListRetrievalMethodCallArgs(p))2407 assert.Equal(t, expected, actual)2408 })2409}2410func TestDataType_BuildDBQuerierListRetrievalMethodArgs(T *testing.T) {2411 T.Parallel()2412 T.Run("obligatory", func(t *testing.T) {2413 t.Parallel()2414 dt := DataType{2415 Name: wordsmith.FromSingularPascalCase("Thing"),2416 }2417 p := buildExampleTodoListProject()2418 expected := `2419package main2420import ()2421func main() {2422 exampleFunction(filter)2423}2424`2425 actual := renderCallArgsToString(t, dt.BuildDBQuerierListRetrievalMethodArgs(p))2426 assert.Equal(t, expected, actual)2427 })2428}2429func TestDataType_BuildMockDataManagerListRetrievalMethodCallArgs(T *testing.T) {2430 T.Parallel()2431 T.Run("obligatory", func(t *testing.T) {2432 t.Parallel()2433 dt := DataType{2434 Name: wordsmith.FromSingularPascalCase("Thing"),2435 }2436 p := buildExampleTodoListProject()2437 expected := `2438package main2439import ()2440func main() {2441 exampleFunction(ctx, filter)2442}2443`2444 actual := renderCallArgsToString(t, dt.BuildMockDataManagerListRetrievalMethodCallArgs(p))2445 assert.Equal(t, expected, actual)2446 })2447}2448func TestDataType_buildVarDeclarationsOfDependentStructsWithOwnerStruct(T *testing.T) {2449 T.Parallel()2450 T.Run("obligatory", func(t *testing.T) {2451 t.Parallel()2452 dt := DataType{2453 Name: wordsmith.FromSingularPascalCase("Thing"),2454 }2455 p := buildExampleTodoListProject()2456 expected := `2457package main2458import (2459 fake "gitlab.com/verygoodsoftwarenotvirus/example/models/v1/fake"2460)2461func main() {2462 exampleThing := fake.BuildFakeThing()2463}2464`2465 actual := renderVariableDeclarationsToString(t, dt.buildVarDeclarationsOfDependentStructsWithOwnerStruct(p))2466 assert.Equal(t, expected, actual)2467 })2468 T.Run("with multiple ownership", func(t *testing.T) {2469 t.Parallel()2470 p := buildExampleTodoListProject()2471 p.DataTypes = BuildOwnershipChain("Thing", "AnotherThing", "YetAnotherThing")2472 for i := range p.DataTypes {2473 p.DataTypes[i].BelongsToUser = true2474 p.DataTypes[i].RestrictedToUser = true2475 }2476 expected := `2477package main2478import (2479 fake "gitlab.com/verygoodsoftwarenotvirus/example/models/v1/fake"2480)2481func main() {2482 exampleThing := fake.BuildFakeThing()2483 exampleAnotherThing := fake.BuildFakeAnotherThing()2484 exampleYetAnotherThing := fake.BuildFakeYetAnotherThing()2485}2486`2487 actual := renderVariableDeclarationsToString(t, p.LastDataType().buildVarDeclarationsOfDependentStructsWithOwnerStruct(p))2488 assert.Equal(t, expected, actual)2489 })2490}2491func TestDataType_buildVarDeclarationsOfDependentStructsWithoutUsingOwnerStruct(T *testing.T) {2492 T.Parallel()2493 T.Run("obligatory", func(t *testing.T) {2494 t.Parallel()2495 dt := DataType{2496 Name: wordsmith.FromSingularPascalCase("Thing"),2497 }2498 p := buildExampleTodoListProject()2499 expected := `2500package main2501import (2502 fake "gitlab.com/verygoodsoftwarenotvirus/example/models/v1/fake"2503)2504func main() {2505 exampleThing := fake.BuildFakeThing()2506}2507`2508 actual := renderVariableDeclarationsToString(t, dt.buildVarDeclarationsOfDependentStructsWithoutUsingOwnerStruct(p))2509 assert.Equal(t, expected, actual)2510 })2511 T.Run("with multiple ownership", func(t *testing.T) {2512 t.Parallel()2513 p := buildExampleTodoListProject()2514 p.DataTypes = BuildOwnershipChain("Thing", "AnotherThing", "YetAnotherThing")2515 for i := range p.DataTypes {2516 p.DataTypes[i].BelongsToUser = true2517 p.DataTypes[i].RestrictedToUser = true2518 }2519 expected := `2520package main2521import (2522 fake "gitlab.com/verygoodsoftwarenotvirus/example/models/v1/fake"2523)2524func main() {2525 exampleUser := fake.BuildFakeUser()2526 exampleThing := fake.BuildFakeThing()2527 exampleThing.BelongsToUser = exampleUser.ID2528 exampleAnotherThing := fake.BuildFakeAnotherThing()2529 exampleAnotherThing.BelongsToUser = exampleUser.ID2530 exampleAnotherThing.BelongsToThing = exampleThing.ID2531 exampleYetAnotherThing := fake.BuildFakeYetAnotherThing()2532 exampleYetAnotherThing.BelongsToAnotherThing = exampleAnotherThing.ID2533 exampleYetAnotherThing.BelongsToUser = exampleUser.ID2534}2535`2536 actual := renderVariableDeclarationsToString(t, p.LastDataType().buildVarDeclarationsOfDependentStructsWithoutUsingOwnerStruct(p))2537 assert.Equal(t, expected, actual)2538 })2539}2540func TestDataType_BuildDependentObjectsForHTTPClientBuildCreationRequestMethodTest(T *testing.T) {2541 T.Parallel()2542 T.Run("obligatory", func(t *testing.T) {2543 t.Parallel()2544 dt := DataType{2545 Name: wordsmith.FromSingularPascalCase("Thing"),2546 }2547 p := buildExampleTodoListProject()2548 expected := `2549package main2550import (2551 fake "gitlab.com/verygoodsoftwarenotvirus/example/models/v1/fake"2552)2553func main() {2554 exampleThing := fake.BuildFakeThing()2555}2556`2557 actual := renderVariableDeclarationsToString(t, dt.BuildDependentObjectsForHTTPClientBuildCreationRequestMethodTest(p))2558 assert.Equal(t, expected, actual)2559 })2560}2561func TestDataType_BuildDependentObjectsForDBQueriersExistenceMethodTest(T *testing.T) {2562 T.Parallel()2563 T.Run("obligatory", func(t *testing.T) {2564 t.Parallel()2565 dt := DataType{2566 Name: wordsmith.FromSingularPascalCase("Thing"),2567 }2568 p := buildExampleTodoListProject()2569 expected := `2570package main2571import (2572 fake "gitlab.com/verygoodsoftwarenotvirus/example/models/v1/fake"2573)2574func main() {2575 exampleThing := fake.BuildFakeThing()2576}2577`2578 actual := renderVariableDeclarationsToString(t, dt.BuildDependentObjectsForDBQueriersExistenceMethodTest(p))2579 assert.Equal(t, expected, actual)2580 })2581}2582func TestDataType_BuildDependentObjectsForDBQueriersCreationMethodTest(T *testing.T) {2583 T.Parallel()2584 T.Run("obligatory", func(t *testing.T) {2585 t.Parallel()2586 dt := DataType{2587 Name: wordsmith.FromSingularPascalCase("Thing"),2588 }2589 p := buildExampleTodoListProject()2590 expected := `2591package main2592import (2593 fake "gitlab.com/verygoodsoftwarenotvirus/example/models/v1/fake"2594)2595func main() {2596 exampleThing := fake.BuildFakeThing()2597 exampleInput := fake.BuildFakeThingCreationInputFromThing(exampleThing)2598}2599`2600 actual := renderVariableDeclarationsToString(t, dt.BuildDependentObjectsForDBQueriersCreationMethodTest(p))2601 assert.Equal(t, expected, actual)2602 })2603}2604func TestDataType_buildVarDeclarationsOfDependentStructsWhereEachStructIsImportant(T *testing.T) {2605 T.Parallel()2606 T.Run("obligatory", func(t *testing.T) {2607 t.Parallel()2608 dt := DataType{2609 Name: wordsmith.FromSingularPascalCase("Thing"),2610 }2611 p := buildExampleTodoListProject()2612 expected := `2613package main2614import (2615 fake "gitlab.com/verygoodsoftwarenotvirus/example/models/v1/fake"2616)2617func main() {2618 exampleThing := fake.BuildFakeThing()2619}2620`2621 actual := renderVariableDeclarationsToString(t, dt.buildVarDeclarationsOfDependentStructsWhereEachStructIsImportant(p))2622 assert.Equal(t, expected, actual)2623 })2624 T.Run("with multiple ownership", func(t *testing.T) {2625 t.Parallel()2626 p := buildExampleTodoListProject()2627 p.DataTypes = BuildOwnershipChain("Thing", "AnotherThing", "YetAnotherThing")2628 for i := range p.DataTypes {2629 p.DataTypes[i].BelongsToUser = true2630 p.DataTypes[i].RestrictedToUser = true2631 }2632 expected := `2633package main2634import (2635 fake "gitlab.com/verygoodsoftwarenotvirus/example/models/v1/fake"2636)2637func main() {2638 exampleThing := fake.BuildFakeThing()2639 exampleAnotherThing := fake.BuildFakeAnotherThing()2640 exampleAnotherThing.BelongsToThing = exampleThing.ID2641 exampleYetAnotherThing := fake.BuildFakeYetAnotherThing()2642 exampleYetAnotherThing.BelongsToAnotherThing = exampleAnotherThing.ID2643}2644`2645 actual := renderVariableDeclarationsToString(t, p.LastDataType().buildVarDeclarationsOfDependentStructsWhereEachStructIsImportant(p))2646 assert.Equal(t, expected, actual)2647 })2648}2649func TestDataType_buildVarDeclarationsOfDependentStructsWhereOnlySomeStructsAreImportant(T *testing.T) {2650 T.Parallel()2651 T.Run("obligatory", func(t *testing.T) {2652 t.Parallel()2653 dt := DataType{2654 Name: wordsmith.FromSingularPascalCase("Thing"),2655 }2656 p := buildExampleTodoListProject()2657 expected := `2658package main2659import (2660 fake "gitlab.com/verygoodsoftwarenotvirus/example/models/v1/fake"2661)2662func main() {2663 exampleThing := fake.BuildFakeThing()2664}2665`2666 actual := renderVariableDeclarationsToString(t, dt.buildVarDeclarationsOfDependentStructsWhereOnlySomeStructsAreImportant(p))2667 assert.Equal(t, expected, actual)2668 })2669 T.Run("with multiple ownership", func(t *testing.T) {2670 t.Parallel()2671 p := buildExampleTodoListProject()2672 p.DataTypes = BuildOwnershipChain("Thing", "AnotherThing", "YetAnotherThing")2673 for i := range p.DataTypes {2674 p.DataTypes[i].BelongsToUser = true2675 p.DataTypes[i].RestrictedToUser = true2676 }2677 expected := `2678package main2679import (2680 fake "gitlab.com/verygoodsoftwarenotvirus/example/models/v1/fake"2681)2682func main() {2683 exampleThing := fake.BuildFakeThing()2684 exampleAnotherThing := fake.BuildFakeAnotherThing()2685 exampleYetAnotherThing := fake.BuildFakeYetAnotherThing()2686}2687`2688 actual := renderVariableDeclarationsToString(t, p.LastDataType().buildVarDeclarationsOfDependentStructsWhereOnlySomeStructsAreImportant(p))2689 assert.Equal(t, expected, actual)2690 })2691}2692func TestDataType_BuildHTTPClientRetrievalMethodTestDependentObjects(T *testing.T) {2693 T.Parallel()2694 T.Run("obligatory", func(t *testing.T) {2695 t.Parallel()2696 dt := DataType{2697 Name: wordsmith.FromSingularPascalCase("Thing"),2698 }2699 p := buildExampleTodoListProject()2700 expected := `2701package main2702import (2703 fake "gitlab.com/verygoodsoftwarenotvirus/example/models/v1/fake"2704)2705func main() {2706 exampleThing := fake.BuildFakeThing()2707}2708`2709 actual := renderVariableDeclarationsToString(t, dt.BuildHTTPClientRetrievalMethodTestDependentObjects(p))2710 assert.Equal(t, expected, actual)2711 })2712}2713func TestDataType_BuildDependentObjectsForHTTPClientBuildArchiveRequestMethodTest(T *testing.T) {2714 T.Parallel()2715 T.Run("obligatory", func(t *testing.T) {2716 t.Parallel()2717 dt := DataType{2718 Name: wordsmith.FromSingularPascalCase("Thing"),2719 }2720 p := buildExampleTodoListProject()2721 expected := `2722package main2723import (2724 fake "gitlab.com/verygoodsoftwarenotvirus/example/models/v1/fake"2725)2726func main() {2727 exampleThing := fake.BuildFakeThing()2728}2729`2730 actual := renderVariableDeclarationsToString(t, dt.BuildDependentObjectsForHTTPClientBuildArchiveRequestMethodTest(p))2731 assert.Equal(t, expected, actual)2732 })2733}2734func TestDataType_BuildDependentObjectsForHTTPClientBuildExistenceRequestMethodTest(T *testing.T) {2735 T.Parallel()2736 T.Run("obligatory", func(t *testing.T) {2737 t.Parallel()2738 dt := DataType{2739 Name: wordsmith.FromSingularPascalCase("Thing"),2740 }2741 p := buildExampleTodoListProject()2742 expected := `2743package main2744import (2745 fake "gitlab.com/verygoodsoftwarenotvirus/example/models/v1/fake"2746)2747func main() {2748 exampleThing := fake.BuildFakeThing()2749}2750`2751 actual := renderVariableDeclarationsToString(t, dt.BuildDependentObjectsForHTTPClientBuildExistenceRequestMethodTest(p))2752 assert.Equal(t, expected, actual)2753 })2754}2755func TestDataType_BuildDependentObjectsForHTTPClientExistenceMethodTest(T *testing.T) {2756 T.Parallel()2757 T.Run("obligatory", func(t *testing.T) {2758 t.Parallel()2759 dt := DataType{2760 Name: wordsmith.FromSingularPascalCase("Thing"),2761 }2762 p := buildExampleTodoListProject()2763 expected := `2764package main2765import (2766 fake "gitlab.com/verygoodsoftwarenotvirus/example/models/v1/fake"2767)2768func main() {2769 exampleThing := fake.BuildFakeThing()2770}2771`2772 actual := renderVariableDeclarationsToString(t, dt.BuildDependentObjectsForHTTPClientExistenceMethodTest(p))2773 assert.Equal(t, expected, actual)2774 })2775}2776func TestDataType_BuildDependentObjectsForHTTPClientBuildRetrievalRequestMethodTest(T *testing.T) {2777 T.Parallel()2778 T.Run("obligatory", func(t *testing.T) {2779 t.Parallel()2780 dt := DataType{2781 Name: wordsmith.FromSingularPascalCase("Thing"),2782 }2783 p := buildExampleTodoListProject()2784 expected := `2785package main2786import (2787 fake "gitlab.com/verygoodsoftwarenotvirus/example/models/v1/fake"2788)2789func main() {2790 exampleThing := fake.BuildFakeThing()2791}2792`2793 actual := renderVariableDeclarationsToString(t, dt.BuildDependentObjectsForHTTPClientBuildRetrievalRequestMethodTest(p))2794 assert.Equal(t, expected, actual)2795 })2796}2797func TestDataType_BuildDependentObjectsForHTTPClientRetrievalMethodTest(T *testing.T) {2798 T.Parallel()2799 T.Run("obligatory", func(t *testing.T) {2800 t.Parallel()2801 dt := DataType{2802 Name: wordsmith.FromSingularPascalCase("Thing"),2803 }2804 p := buildExampleTodoListProject()2805 expected := `2806package main2807import (2808 fake "gitlab.com/verygoodsoftwarenotvirus/example/models/v1/fake"2809)2810func main() {2811 exampleThing := fake.BuildFakeThing()2812}2813`2814 actual := renderVariableDeclarationsToString(t, dt.BuildDependentObjectsForHTTPClientRetrievalMethodTest(p))2815 assert.Equal(t, expected, actual)2816 })2817}2818func TestDataType_BuildDependentObjectsForHTTPClientArchiveMethodTest(T *testing.T) {2819 T.Parallel()2820 T.Run("obligatory", func(t *testing.T) {2821 t.Parallel()2822 dt := DataType{2823 Name: wordsmith.FromSingularPascalCase("Thing"),2824 }2825 p := buildExampleTodoListProject()2826 expected := `2827package main2828import (2829 fake "gitlab.com/verygoodsoftwarenotvirus/example/models/v1/fake"2830)2831func main() {2832 exampleThing := fake.BuildFakeThing()2833}2834`2835 actual := renderVariableDeclarationsToString(t, dt.BuildDependentObjectsForHTTPClientArchiveMethodTest(p))2836 assert.Equal(t, expected, actual)2837 })2838}2839func TestDataType_buildDependentObjectsForHTTPClientListRetrievalTest(T *testing.T) {2840 T.Parallel()2841 T.Run("obligatory", func(t *testing.T) {2842 t.Parallel()2843 p := buildExampleTodoListProject()2844 p.DataTypes = BuildOwnershipChain("Thing", "AnotherThing", "YetAnotherThing")2845 expected := `2846package main2847import (2848 fake "gitlab.com/verygoodsoftwarenotvirus/example/models/v1/fake"2849)2850func main() {2851 exampleThing := fake.BuildFakeThing()2852 exampleAnotherThing := fake.BuildFakeAnotherThing()2853}2854`2855 actual := renderVariableDeclarationsToString(t, p.LastDataType().buildDependentObjectsForHTTPClientListRetrievalTest(p))2856 assert.Equal(t, expected, actual)2857 })2858}2859func TestDataType_BuildDependentObjectsForHTTPClientListRetrievalTest(T *testing.T) {2860 T.Parallel()2861 T.Run("obligatory", func(t *testing.T) {2862 t.Parallel()2863 p := buildExampleTodoListProject()2864 p.DataTypes = BuildOwnershipChain("Thing", "AnotherThing", "YetAnotherThing")2865 expected := `2866package main2867import (2868 fake "gitlab.com/verygoodsoftwarenotvirus/example/models/v1/fake"2869)2870func main() {2871 exampleThing := fake.BuildFakeThing()2872 exampleAnotherThing := fake.BuildFakeAnotherThing()2873}2874`2875 actual := renderVariableDeclarationsToString(t, p.LastDataType().BuildDependentObjectsForHTTPClientListRetrievalTest(p))2876 assert.Equal(t, expected, actual)2877 })2878}2879func TestDataType_BuildDependentObjectsForHTTPClientBuildListRetrievalRequestMethodTest(T *testing.T) {2880 T.Parallel()2881 T.Run("obligatory", func(t *testing.T) {2882 t.Parallel()2883 p := buildExampleTodoListProject()2884 p.DataTypes = BuildOwnershipChain("Thing", "AnotherThing", "YetAnotherThing")2885 expected := `2886package main2887import (2888 fake "gitlab.com/verygoodsoftwarenotvirus/example/models/v1/fake"2889)2890func main() {2891 exampleThing := fake.BuildFakeThing()2892 exampleAnotherThing := fake.BuildFakeAnotherThing()2893}2894`2895 actual := renderVariableDeclarationsToString(t, p.LastDataType().BuildDependentObjectsForHTTPClientBuildListRetrievalRequestMethodTest(p))2896 assert.Equal(t, expected, actual)2897 })2898}2899func TestDataType_buildVarDeclarationsOfDependentStructsForUpdateFunction(T *testing.T) {2900 T.Parallel()2901 T.Run("obligatory", func(t *testing.T) {2902 t.Parallel()2903 p := buildExampleTodoListProject()2904 p.DataTypes = BuildOwnershipChain("Thing", "AnotherThing", "YetAnotherThing")2905 expected := `2906package main2907import (2908 fake "gitlab.com/verygoodsoftwarenotvirus/example/models/v1/fake"2909)2910func main() {2911 exampleThing := fake.BuildFakeThing()2912 exampleYetAnotherThing := fake.BuildFakeYetAnotherThing()2913}2914`2915 actual := renderVariableDeclarationsToString(t, p.LastDataType().buildVarDeclarationsOfDependentStructsForUpdateFunction(p))2916 assert.Equal(t, expected, actual)2917 })2918}2919func TestDataType_BuildDependentObjectsForHTTPClientUpdateMethodTest(T *testing.T) {2920 T.Parallel()2921 T.Run("obligatory", func(t *testing.T) {2922 t.Parallel()2923 p := buildExampleTodoListProject()2924 p.DataTypes = BuildOwnershipChain("Thing", "AnotherThing", "YetAnotherThing")2925 expected := `2926package main2927import (2928 fake "gitlab.com/verygoodsoftwarenotvirus/example/models/v1/fake"2929)2930func main() {2931 exampleThing := fake.BuildFakeThing()2932 exampleYetAnotherThing := fake.BuildFakeYetAnotherThing()2933}2934`2935 actual := renderVariableDeclarationsToString(t, p.LastDataType().BuildDependentObjectsForHTTPClientUpdateMethodTest(p))2936 assert.Equal(t, expected, actual)2937 })2938}2939func TestDataType_BuildDependentObjectsForHTTPClientBuildUpdateRequestMethodTest(T *testing.T) {2940 T.Parallel()2941 T.Run("obligatory", func(t *testing.T) {2942 t.Parallel()2943 p := buildExampleTodoListProject()2944 p.DataTypes = BuildOwnershipChain("Thing", "AnotherThing", "YetAnotherThing")2945 expected := `2946package main2947import (2948 fake "gitlab.com/verygoodsoftwarenotvirus/example/models/v1/fake"2949)2950func main() {2951 exampleThing := fake.BuildFakeThing()2952 exampleYetAnotherThing := fake.BuildFakeYetAnotherThing()2953}2954`2955 actual := renderVariableDeclarationsToString(t, p.LastDataType().BuildDependentObjectsForHTTPClientBuildUpdateRequestMethodTest(p))2956 assert.Equal(t, expected, actual)2957 })2958}2959func TestDataType_BuildDependentObjectsForHTTPClientCreationMethodTest(T *testing.T) {2960 T.Parallel()2961 T.Run("obligatory", func(t *testing.T) {2962 t.Parallel()2963 p := buildExampleTodoListProject()2964 p.DataTypes = BuildOwnershipChain("Thing", "AnotherThing", "YetAnotherThing")2965 expected := `2966package main2967import (2968 fake "gitlab.com/verygoodsoftwarenotvirus/example/models/v1/fake"2969)2970func main() {2971 exampleThing := fake.BuildFakeThing()2972 exampleAnotherThing := fake.BuildFakeAnotherThing()2973 exampleYetAnotherThing := fake.BuildFakeYetAnotherThing()2974 exampleYetAnotherThing.BelongsToAnotherThing = exampleAnotherThing.ID2975}2976`2977 actual := renderVariableDeclarationsToString(t, p.LastDataType().BuildDependentObjectsForHTTPClientCreationMethodTest(p))2978 assert.Equal(t, expected, actual)2979 })2980}2981func TestDataType_BuildFormatStringForHTTPClientExistenceMethodTest(T *testing.T) {2982 T.Parallel()2983 T.Run("obligatory", func(t *testing.T) {2984 t.Parallel()2985 p := buildExampleTodoListProject()2986 p.DataTypes = BuildOwnershipChain("Thing", "AnotherThing", "YetAnotherThing")2987 expected := "/api/v1/things/%d/another_things/%d/yet_another_things/%d"2988 actual := p.LastDataType().BuildFormatStringForHTTPClientExistenceMethodTest(p)2989 assert.Equal(t, expected, actual)2990 })2991}2992func TestDataType_BuildFormatStringForHTTPClientRetrievalMethodTest(T *testing.T) {2993 T.Parallel()2994 T.Run("obligatory", func(t *testing.T) {2995 t.Parallel()2996 p := buildExampleTodoListProject()2997 p.DataTypes = BuildOwnershipChain("Thing", "AnotherThing", "YetAnotherThing")2998 expected := "/api/v1/things/%d/another_things/%d/yet_another_things/%d"2999 actual := p.LastDataType().BuildFormatStringForHTTPClientRetrievalMethodTest(p)3000 assert.Equal(t, expected, actual)3001 })3002}3003func TestDataType_BuildFormatStringForHTTPClientUpdateMethodTest(T *testing.T) {3004 T.Parallel()3005 T.Run("obligatory", func(t *testing.T) {3006 t.Parallel()3007 p := buildExampleTodoListProject()3008 p.DataTypes = BuildOwnershipChain("Thing", "AnotherThing", "YetAnotherThing")3009 expected := "/api/v1/things/%d/another_things/%d/yet_another_things/%d"3010 actual := p.LastDataType().BuildFormatStringForHTTPClientUpdateMethodTest(p)3011 assert.Equal(t, expected, actual)3012 })3013}3014func TestDataType_BuildFormatStringForHTTPClientArchiveMethodTest(T *testing.T) {3015 T.Parallel()3016 T.Run("obligatory", func(t *testing.T) {3017 t.Parallel()3018 p := buildExampleTodoListProject()3019 p.DataTypes = BuildOwnershipChain("Thing", "AnotherThing", "YetAnotherThing")3020 expected := "/api/v1/things/%d/another_things/%d/yet_another_things/%d"3021 actual := p.LastDataType().BuildFormatStringForHTTPClientArchiveMethodTest(p)3022 assert.Equal(t, expected, actual)3023 })3024}3025func TestDataType_BuildFormatStringForHTTPClientListMethodTest(T *testing.T) {3026 T.Parallel()3027 T.Run("obligatory", func(t *testing.T) {3028 t.Parallel()3029 p := buildExampleTodoListProject()3030 p.DataTypes = BuildOwnershipChain("Thing", "AnotherThing", "YetAnotherThing")3031 expected := "/api/v1/things/%d/another_things/%d/yet_another_things"3032 actual := p.LastDataType().BuildFormatStringForHTTPClientListMethodTest(p)3033 assert.Equal(t, expected, actual)3034 })3035}3036func TestDataType_BuildFormatStringForHTTPClientSearchMethodTest(T *testing.T) {3037 T.Parallel()3038 T.Run("obligatory", func(t *testing.T) {3039 t.Parallel()3040 p := buildExampleTodoListProject()3041 p.DataTypes = BuildOwnershipChain("Thing", "AnotherThing", "YetAnotherThing")3042 expected := "/api/v1/yet_another_things/search"3043 actual := p.LastDataType().BuildFormatStringForHTTPClientSearchMethodTest()3044 assert.Equal(t, expected, actual)3045 })3046}3047func TestDataType_BuildFormatStringForHTTPClientCreateMethodTest(T *testing.T) {3048 T.Parallel()3049 T.Run("obligatory", func(t *testing.T) {3050 t.Parallel()3051 p := buildExampleTodoListProject()3052 p.DataTypes = BuildOwnershipChain("Thing", "AnotherThing", "YetAnotherThing")3053 expected := "/api/v1/things/%d/another_things/%d/yet_another_things"3054 actual := p.LastDataType().BuildFormatStringForHTTPClientCreateMethodTest(p)3055 assert.Equal(t, expected, actual)3056 })3057}3058func TestDataType_BuildFormatCallArgsForHTTPClientRetrievalMethodTest(T *testing.T) {3059 T.Parallel()3060 T.Run("obligatory", func(t *testing.T) {3061 t.Parallel()3062 dt := DataType{3063 Name: wordsmith.FromSingularPascalCase("Thing"),3064 }3065 p := buildExampleTodoListProject()3066 expected := `3067package main3068import ()3069func main() {3070 exampleFunction(exampleThing.ID)3071}3072`3073 actual := renderCallArgsToString(t, dt.BuildFormatCallArgsForHTTPClientRetrievalMethodTest(p))3074 assert.Equal(t, expected, actual)3075 })3076 T.Run("with multiple ownership", func(t *testing.T) {3077 t.Parallel()3078 p := buildExampleTodoListProject()3079 p.DataTypes = BuildOwnershipChain("Thing", "AnotherThing", "YetAnotherThing")3080 for i := range p.DataTypes {3081 p.DataTypes[i].BelongsToUser = true3082 p.DataTypes[i].RestrictedToUser = true3083 }3084 expected := `3085package main3086import ()3087func main() {3088 exampleFunction(exampleThing.ID, exampleAnotherThing.ID, exampleYetAnotherThing.ID)3089}3090`3091 actual := renderCallArgsToString(t, p.LastDataType().BuildFormatCallArgsForHTTPClientRetrievalMethodTest(p))3092 assert.Equal(t, expected, actual)3093 })3094}3095func TestDataType_BuildFormatCallArgsForHTTPClientExistenceMethodTest(T *testing.T) {3096 T.Parallel()3097 T.Run("obligatory", func(t *testing.T) {3098 t.Parallel()3099 dt := DataType{3100 Name: wordsmith.FromSingularPascalCase("Thing"),3101 }3102 p := buildExampleTodoListProject()3103 expected := `3104package main3105import ()3106func main() {3107 exampleFunction(exampleThing.ID)3108}3109`3110 actual := renderCallArgsToString(t, dt.BuildFormatCallArgsForHTTPClientExistenceMethodTest(p))3111 assert.Equal(t, expected, actual)3112 })3113 T.Run("with multiple ownership", func(t *testing.T) {3114 t.Parallel()3115 p := buildExampleTodoListProject()3116 p.DataTypes = BuildOwnershipChain("Thing", "AnotherThing", "YetAnotherThing")3117 for i := range p.DataTypes {3118 p.DataTypes[i].BelongsToUser = true3119 p.DataTypes[i].RestrictedToUser = true3120 }3121 expected := `3122package main3123import ()3124func main() {3125 exampleFunction(exampleThing.ID, exampleAnotherThing.ID, exampleYetAnotherThing.ID)3126}3127`3128 actual := renderCallArgsToString(t, p.LastDataType().BuildFormatCallArgsForHTTPClientExistenceMethodTest(p))3129 assert.Equal(t, expected, actual)3130 })3131}3132func TestDataType_BuildFormatCallArgsForHTTPClientListMethodTest(T *testing.T) {3133 T.Parallel()3134 T.Run("obligatory", func(t *testing.T) {3135 t.Parallel()3136 dt := DataType{3137 Name: wordsmith.FromSingularPascalCase("Thing"),3138 }3139 p := buildExampleTodoListProject()3140 expected := `3141package main3142import ()3143func main() {3144 exampleFunction()3145}3146`3147 actual := renderCallArgsToString(t, dt.BuildFormatCallArgsForHTTPClientListMethodTest(p))3148 assert.Equal(t, expected, actual)3149 })3150 T.Run("with multiple ownership", func(t *testing.T) {3151 t.Parallel()3152 p := buildExampleTodoListProject()3153 p.DataTypes = BuildOwnershipChain("Thing", "AnotherThing", "YetAnotherThing")3154 for i := range p.DataTypes {3155 p.DataTypes[i].BelongsToUser = true3156 p.DataTypes[i].RestrictedToUser = true3157 }3158 expected := `3159package main3160import ()3161func main() {3162 exampleFunction(exampleThing.ID, exampleAnotherThing.ID)3163}3164`3165 actual := renderCallArgsToString(t, p.LastDataType().BuildFormatCallArgsForHTTPClientListMethodTest(p))3166 assert.Equal(t, expected, actual)3167 })3168}3169func TestDataType_BuildFormatCallArgsForHTTPClientCreationMethodTest(T *testing.T) {3170 T.Parallel()3171 T.Run("obligatory", func(t *testing.T) {3172 t.Parallel()3173 dt := DataType{3174 Name: wordsmith.FromSingularPascalCase("Thing"),3175 }3176 p := buildExampleTodoListProject()3177 expected := `3178package main3179import ()3180func main() {3181 exampleFunction()3182}3183`3184 actual := renderCallArgsToString(t, dt.BuildFormatCallArgsForHTTPClientCreationMethodTest(p))3185 assert.Equal(t, expected, actual)3186 })3187 T.Run("with multiple ownership", func(t *testing.T) {3188 t.Parallel()3189 p := buildExampleTodoListProject()3190 p.DataTypes = BuildOwnershipChain("Thing", "AnotherThing", "YetAnotherThing")3191 for i := range p.DataTypes {3192 p.DataTypes[i].BelongsToUser = true3193 p.DataTypes[i].RestrictedToUser = true3194 }3195 expected := `3196package main3197import ()3198func main() {3199 exampleFunction(exampleThing.ID, exampleAnotherThing.ID)3200}3201`3202 actual := renderCallArgsToString(t, p.LastDataType().BuildFormatCallArgsForHTTPClientCreationMethodTest(p))3203 assert.Equal(t, expected, actual)3204 })3205}3206func TestDataType_BuildFormatCallArgsForHTTPClientUpdateTest(T *testing.T) {3207 T.Parallel()3208 T.Run("obligatory", func(t *testing.T) {3209 t.Parallel()3210 dt := DataType{3211 Name: wordsmith.FromSingularPascalCase("Thing"),3212 }3213 p := buildExampleTodoListProject()3214 expected := `3215package main3216import ()3217func main() {3218 exampleFunction(exampleThing.ID)3219}3220`3221 actual := renderCallArgsToString(t, dt.BuildFormatCallArgsForHTTPClientUpdateTest(p))3222 assert.Equal(t, expected, actual)3223 })3224 T.Run("with multiple ownership", func(t *testing.T) {3225 t.Parallel()3226 p := buildExampleTodoListProject()3227 p.DataTypes = BuildOwnershipChain("Thing", "AnotherThing", "YetAnotherThing")3228 for i := range p.DataTypes {3229 p.DataTypes[i].BelongsToUser = true3230 p.DataTypes[i].RestrictedToUser = true3231 }3232 expected := `3233package main3234import ()3235func main() {3236 exampleFunction(exampleThing.ID, exampleYetAnotherThing.BelongsToAnotherThing, exampleYetAnotherThing.ID)3237}3238`3239 actual := renderCallArgsToString(t, p.LastDataType().BuildFormatCallArgsForHTTPClientUpdateTest(p))3240 assert.Equal(t, expected, actual)3241 })3242}3243func TestDataType_BuildArgsForHTTPClientExistenceRequestBuildingMethod(T *testing.T) {3244 T.Parallel()3245 T.Run("obligatory", func(t *testing.T) {3246 t.Parallel()3247 dt := DataType{3248 Name: wordsmith.FromSingularPascalCase("Thing"),3249 }3250 p := buildExampleTodoListProject()3251 expected := `3252package main3253import ()3254func main() {3255 exampleFunction(ctx, thingID)3256}3257`3258 actual := renderCallArgsToString(t, dt.BuildArgsForHTTPClientExistenceRequestBuildingMethod(p))3259 assert.Equal(t, expected, actual)3260 })3261 T.Run("with multiple ownership", func(t *testing.T) {3262 t.Parallel()3263 p := buildExampleTodoListProject()3264 p.DataTypes = BuildOwnershipChain("Thing", "AnotherThing", "YetAnotherThing")3265 for i := range p.DataTypes {3266 p.DataTypes[i].BelongsToUser = true3267 p.DataTypes[i].RestrictedToUser = true3268 }3269 expected := `3270package main3271import ()3272func main() {3273 exampleFunction(ctx, thingID, anotherThingID, yetAnotherThingID)3274}3275`3276 actual := renderCallArgsToString(t, p.LastDataType().BuildArgsForHTTPClientExistenceRequestBuildingMethod(p))3277 assert.Equal(t, expected, actual)3278 })3279}3280func TestDataType_BuildParamsForHTTPClientExistenceRequestBuildingMethod(T *testing.T) {3281 T.Parallel()3282 T.Run("obligatory", func(t *testing.T) {3283 t.Parallel()3284 dt := DataType{3285 Name: wordsmith.FromSingularPascalCase("Thing"),3286 }3287 p := buildExampleTodoListProject()3288 expected := `3289package main3290import (3291 "context"3292)3293func example(ctx context.Context, thingID uint64) {}3294`3295 actual := renderFunctionParamsToString(t, dt.BuildParamsForHTTPClientExistenceRequestBuildingMethod(p))3296 assert.Equal(t, expected, actual)3297 })3298 T.Run("with multiple ownership", func(t *testing.T) {3299 t.Parallel()3300 p := buildExampleTodoListProject()3301 p.DataTypes = BuildOwnershipChain("Thing", "AnotherThing", "YetAnotherThing")3302 for i := range p.DataTypes {3303 p.DataTypes[i].BelongsToUser = true3304 p.DataTypes[i].RestrictedToUser = true3305 }3306 expected := `3307package main3308import (3309 "context"3310)3311func example(ctx context.Context, thingID, anotherThingID, yetAnotherThingID uint64) {}3312`3313 actual := renderFunctionParamsToString(t, p.LastDataType().BuildParamsForHTTPClientExistenceRequestBuildingMethod(p))3314 assert.Equal(t, expected, actual)3315 })3316}3317func TestDataType_BuildParamsForHTTPClientExistenceMethod(T *testing.T) {3318 T.Parallel()3319 T.Run("obligatory", func(t *testing.T) {3320 t.Parallel()3321 dt := DataType{3322 Name: wordsmith.FromSingularPascalCase("Thing"),3323 }3324 p := buildExampleTodoListProject()3325 expected := `3326package main3327import (3328 "context"3329)3330func example(ctx context.Context, thingID uint64) {}3331`3332 actual := renderFunctionParamsToString(t, dt.BuildParamsForHTTPClientExistenceMethod(p))3333 assert.Equal(t, expected, actual)3334 })3335 T.Run("with multiple ownership", func(t *testing.T) {3336 t.Parallel()3337 p := buildExampleTodoListProject()3338 p.DataTypes = BuildOwnershipChain("Thing", "AnotherThing", "YetAnotherThing")3339 for i := range p.DataTypes {3340 p.DataTypes[i].BelongsToUser = true3341 p.DataTypes[i].RestrictedToUser = true3342 }3343 expected := `3344package main3345import (3346 "context"3347)3348func example(ctx context.Context, thingID, anotherThingID, yetAnotherThingID uint64) {}3349`3350 actual := renderFunctionParamsToString(t, p.LastDataType().BuildParamsForHTTPClientExistenceMethod(p))3351 assert.Equal(t, expected, actual)3352 })3353}3354func TestDataType_BuildArgsForHTTPClientCreateRequestBuildingMethod(T *testing.T) {3355 T.Parallel()3356 T.Run("obligatory", func(t *testing.T) {3357 t.Parallel()3358 dt := DataType{3359 Name: wordsmith.FromSingularPascalCase("Thing"),3360 }3361 p := buildExampleTodoListProject()3362 expected := `3363package main3364import ()3365func main() {3366 exampleFunction(ctx, input)3367}3368`3369 actual := renderCallArgsToString(t, dt.BuildArgsForHTTPClientCreateRequestBuildingMethod(p))3370 assert.Equal(t, expected, actual)3371 })3372 T.Run("with multiple ownership", func(t *testing.T) {3373 t.Parallel()3374 p := buildExampleTodoListProject()3375 p.DataTypes = BuildOwnershipChain("Thing", "AnotherThing", "YetAnotherThing")3376 for i := range p.DataTypes {3377 p.DataTypes[i].BelongsToUser = true3378 p.DataTypes[i].RestrictedToUser = true3379 }3380 expected := `3381package main3382import ()3383func main() {3384 exampleFunction(ctx, thingID, input)3385}3386`3387 actual := renderCallArgsToString(t, p.LastDataType().BuildArgsForHTTPClientCreateRequestBuildingMethod(p))3388 assert.Equal(t, expected, actual)3389 })3390}3391func TestDataType_BuildArgsForHTTPClientRetrievalRequestBuildingMethod(T *testing.T) {3392 T.Parallel()3393 T.Run("obligatory", func(t *testing.T) {3394 t.Parallel()3395 dt := DataType{3396 Name: wordsmith.FromSingularPascalCase("Thing"),3397 }3398 p := buildExampleTodoListProject()3399 expected := `3400package main3401import ()3402func main() {3403 exampleFunction(ctx, thingID)3404}3405`3406 actual := renderCallArgsToString(t, dt.BuildArgsForHTTPClientRetrievalRequestBuildingMethod(p))3407 assert.Equal(t, expected, actual)3408 })3409 T.Run("with multiple ownership", func(t *testing.T) {3410 t.Parallel()3411 p := buildExampleTodoListProject()3412 p.DataTypes = BuildOwnershipChain("Thing", "AnotherThing", "YetAnotherThing")3413 for i := range p.DataTypes {3414 p.DataTypes[i].BelongsToUser = true3415 p.DataTypes[i].RestrictedToUser = true3416 }3417 expected := `3418package main3419import ()3420func main() {3421 exampleFunction(ctx, thingID, anotherThingID, yetAnotherThingID)3422}3423`3424 actual := renderCallArgsToString(t, p.LastDataType().BuildArgsForHTTPClientRetrievalRequestBuildingMethod(p))3425 assert.Equal(t, expected, actual)3426 })3427}3428func TestDataType_BuildParamsForHTTPClientRetrievalRequestBuildingMethod(T *testing.T) {3429 T.Parallel()3430 T.Run("obligatory", func(t *testing.T) {3431 t.Parallel()3432 dt := DataType{3433 Name: wordsmith.FromSingularPascalCase("Thing"),3434 }3435 p := buildExampleTodoListProject()3436 expected := `3437package main3438import (3439 "context"3440)3441func example(ctx context.Context, thingID uint64) {}3442`3443 actual := renderFunctionParamsToString(t, dt.BuildParamsForHTTPClientRetrievalRequestBuildingMethod(p))3444 assert.Equal(t, expected, actual)3445 })3446 T.Run("with multiple ownership", func(t *testing.T) {3447 t.Parallel()3448 p := buildExampleTodoListProject()3449 p.DataTypes = BuildOwnershipChain("Thing", "AnotherThing", "YetAnotherThing")3450 for i := range p.DataTypes {3451 p.DataTypes[i].BelongsToUser = true3452 p.DataTypes[i].RestrictedToUser = true3453 }3454 expected := `3455package main3456import (3457 "context"3458)3459func example(ctx context.Context, thingID, anotherThingID, yetAnotherThingID uint64) {}3460`3461 actual := renderFunctionParamsToString(t, p.LastDataType().BuildParamsForHTTPClientRetrievalRequestBuildingMethod(p))3462 assert.Equal(t, expected, actual)3463 })3464}3465func TestDataType_BuildParamsForHTTPClientRetrievalMethod(T *testing.T) {3466 T.Parallel()3467 T.Run("as call", func(t *testing.T) {3468 t.Parallel()3469 dt := DataType{3470 Name: wordsmith.FromSingularPascalCase("Thing"),3471 }3472 p := buildExampleTodoListProject()3473 expected := `3474package main3475import ()3476func example(ctx, thingID) {}3477`3478 actual := renderFunctionParamsToString(t, dt.BuildParamsForHTTPClientRetrievalMethod(p, true))3479 assert.Equal(t, expected, actual)3480 })3481 T.Run("not as call", func(t *testing.T) {3482 t.Parallel()3483 dt := DataType{3484 Name: wordsmith.FromSingularPascalCase("Thing"),3485 }3486 p := buildExampleTodoListProject()3487 expected := `3488package main3489import (3490 "context"3491)3492func example(ctx context.Context, thingID uint64) {}3493`3494 actual := renderFunctionParamsToString(t, dt.BuildParamsForHTTPClientRetrievalMethod(p, false))3495 assert.Equal(t, expected, actual)3496 })3497 T.Run("as call with multiple ownership", func(t *testing.T) {3498 t.Parallel()3499 p := buildExampleTodoListProject()3500 p.DataTypes = BuildOwnershipChain("Thing", "AnotherThing", "YetAnotherThing")3501 for i := range p.DataTypes {3502 p.DataTypes[i].BelongsToUser = true3503 p.DataTypes[i].RestrictedToUser = true3504 }3505 expected := `3506package main3507import ()3508func example(ctx, thingID, anotherThingID, yetAnotherThingID) {}3509`3510 actual := renderFunctionParamsToString(t, p.LastDataType().BuildParamsForHTTPClientRetrievalMethod(p, true))3511 assert.Equal(t, expected, actual)3512 })3513 T.Run("not as call with multiple ownership", func(t *testing.T) {3514 t.Parallel()3515 p := buildExampleTodoListProject()3516 p.DataTypes = BuildOwnershipChain("Thing", "AnotherThing", "YetAnotherThing")3517 for i := range p.DataTypes {3518 p.DataTypes[i].BelongsToUser = true3519 p.DataTypes[i].RestrictedToUser = true3520 }3521 expected := `3522package main3523import (3524 "context"3525)3526func example(ctx context.Context, thingID, anotherThingID, yetAnotherThingID uint64) {}3527`3528 actual := renderFunctionParamsToString(t, p.LastDataType().BuildParamsForHTTPClientRetrievalMethod(p, false))3529 assert.Equal(t, expected, actual)3530 })3531}3532func TestDataType_BuildParamsForHTTPClientCreateRequestBuildingMethod(T *testing.T) {3533 T.Parallel()3534 T.Run("obligatory", func(t *testing.T) {3535 t.Parallel()3536 dt := DataType{3537 Name: wordsmith.FromSingularPascalCase("Thing"),3538 }3539 p := buildExampleTodoListProject()3540 expected := `3541package main3542import (3543 "context"3544 v1 "gitlab.com/verygoodsoftwarenotvirus/example/models/v1"3545)3546func example(ctx context.Context, input *v1.ThingCreationInput) {}3547`3548 actual := renderFunctionParamsToString(t, dt.BuildParamsForHTTPClientCreateRequestBuildingMethod(p))3549 assert.Equal(t, expected, actual)3550 })3551 T.Run("with multiple ownership", func(t *testing.T) {3552 t.Parallel()3553 p := buildExampleTodoListProject()3554 p.DataTypes = BuildOwnershipChain("Thing", "AnotherThing", "YetAnotherThing")3555 for i := range p.DataTypes {3556 p.DataTypes[i].BelongsToUser = true3557 p.DataTypes[i].RestrictedToUser = true3558 }3559 expected := `3560package main3561import (3562 "context"3563 v1 "gitlab.com/verygoodsoftwarenotvirus/example/models/v1"3564)3565func example(ctx context.Context, thingID uint64, input *v1.YetAnotherThingCreationInput) {}3566`3567 actual := renderFunctionParamsToString(t, p.LastDataType().BuildParamsForHTTPClientCreateRequestBuildingMethod(p))3568 assert.Equal(t, expected, actual)3569 })3570}3571func TestDataType_BuildParamsForHTTPClientCreateMethod(T *testing.T) {3572 T.Parallel()3573 T.Run("obligatory", func(t *testing.T) {3574 t.Parallel()3575 dt := DataType{3576 Name: wordsmith.FromSingularPascalCase("Thing"),3577 }3578 p := buildExampleTodoListProject()3579 expected := `3580package main3581import (3582 "context"3583 v1 "gitlab.com/verygoodsoftwarenotvirus/example/models/v1"3584)3585func example(ctx context.Context, input *v1.ThingCreationInput) {}3586`3587 actual := renderFunctionParamsToString(t, dt.BuildParamsForHTTPClientCreateMethod(p))3588 assert.Equal(t, expected, actual)3589 })3590 T.Run("with multiple ownership", func(t *testing.T) {3591 t.Parallel()3592 p := buildExampleTodoListProject()3593 p.DataTypes = BuildOwnershipChain("Thing", "AnotherThing", "YetAnotherThing")3594 for i := range p.DataTypes {3595 p.DataTypes[i].BelongsToUser = true3596 p.DataTypes[i].RestrictedToUser = true3597 }3598 expected := `3599package main3600import (3601 "context"3602 v1 "gitlab.com/verygoodsoftwarenotvirus/example/models/v1"3603)3604func example(ctx context.Context, thingID uint64, input *v1.YetAnotherThingCreationInput) {}3605`3606 actual := renderFunctionParamsToString(t, p.LastDataType().BuildParamsForHTTPClientCreateMethod(p))3607 assert.Equal(t, expected, actual)3608 })3609}3610func TestDataType_BuildParamsForHTTPClientUpdateRequestBuildingMethod(T *testing.T) {3611 T.Parallel()3612 T.Run("obligatory", func(t *testing.T) {3613 t.Parallel()3614 dt := DataType{3615 Name: wordsmith.FromSingularPascalCase("Thing"),3616 }3617 p := buildExampleTodoListProject()3618 expected := `3619package main3620import (3621 "context"3622 v1 "gitlab.com/verygoodsoftwarenotvirus/example/models/v1"3623)3624func example(ctx context.Context, thing *v1.Thing) {}3625`3626 actual := renderFunctionParamsToString(t, dt.BuildParamsForHTTPClientUpdateRequestBuildingMethod(p))3627 assert.Equal(t, expected, actual)3628 })3629 T.Run("with multiple ownership", func(t *testing.T) {3630 t.Parallel()3631 p := buildExampleTodoListProject()3632 p.DataTypes = BuildOwnershipChain("Thing", "AnotherThing", "YetAnotherThing")3633 for i := range p.DataTypes {3634 p.DataTypes[i].BelongsToUser = true3635 p.DataTypes[i].RestrictedToUser = true3636 }3637 expected := `3638package main3639import (3640 "context"3641 v1 "gitlab.com/verygoodsoftwarenotvirus/example/models/v1"3642)3643func example(ctx context.Context, thingID uint64, yetAnotherThing *v1.YetAnotherThing) {}3644`3645 actual := renderFunctionParamsToString(t, p.LastDataType().BuildParamsForHTTPClientUpdateRequestBuildingMethod(p))3646 assert.Equal(t, expected, actual)3647 })3648}3649func TestDataType_BuildArgsForHTTPClientUpdateRequestBuildingMethod(T *testing.T) {3650 T.Parallel()3651 T.Run("obligatory", func(t *testing.T) {3652 t.Parallel()3653 dt := DataType{3654 Name: wordsmith.FromSingularPascalCase("Thing"),3655 }3656 p := buildExampleTodoListProject()3657 expected := `3658package main3659import ()3660func main() {3661 exampleFunction(ctx, thing)3662}3663`3664 actual := renderCallArgsToString(t, dt.BuildArgsForHTTPClientUpdateRequestBuildingMethod(p))3665 assert.Equal(t, expected, actual)3666 })3667 T.Run("with multiple ownership", func(t *testing.T) {3668 t.Parallel()3669 p := buildExampleTodoListProject()3670 p.DataTypes = BuildOwnershipChain("Thing", "AnotherThing", "YetAnotherThing")3671 for i := range p.DataTypes {3672 p.DataTypes[i].BelongsToUser = true3673 p.DataTypes[i].RestrictedToUser = true3674 }3675 expected := `3676package main3677import ()3678func main() {3679 exampleFunction(ctx, thingID, yetAnotherThing)3680}3681`3682 actual := renderCallArgsToString(t, p.LastDataType().BuildArgsForHTTPClientUpdateRequestBuildingMethod(p))3683 assert.Equal(t, expected, actual)3684 })3685}3686func TestDataType_BuildParamsForHTTPClientUpdateMethod(T *testing.T) {3687 T.Parallel()3688 T.Run("obligatory", func(t *testing.T) {3689 t.Parallel()3690 dt := DataType{3691 Name: wordsmith.FromSingularPascalCase("Thing"),3692 }3693 p := buildExampleTodoListProject()3694 expected := `3695package main3696import (3697 "context"3698 v1 "gitlab.com/verygoodsoftwarenotvirus/example/models/v1"3699)3700func example(ctx context.Context, thing *v1.Thing) {}3701`3702 actual := renderFunctionParamsToString(t, dt.BuildParamsForHTTPClientUpdateMethod(p))3703 assert.Equal(t, expected, actual)3704 })3705 T.Run("with multiple ownership", func(t *testing.T) {3706 t.Parallel()3707 p := buildExampleTodoListProject()3708 p.DataTypes = BuildOwnershipChain("Thing", "AnotherThing", "YetAnotherThing")3709 for i := range p.DataTypes {3710 p.DataTypes[i].BelongsToUser = true3711 p.DataTypes[i].RestrictedToUser = true3712 }3713 expected := `3714package main3715import (3716 "context"3717 v1 "gitlab.com/verygoodsoftwarenotvirus/example/models/v1"3718)3719func example(ctx context.Context, thingID uint64, yetAnotherThing *v1.YetAnotherThing) {}3720`3721 actual := renderFunctionParamsToString(t, p.LastDataType().BuildParamsForHTTPClientUpdateMethod(p))3722 assert.Equal(t, expected, actual)3723 })3724}3725func TestDataType_BuildParamsForHTTPClientArchiveRequestBuildingMethod(T *testing.T) {3726 T.Parallel()3727 T.Run("obligatory", func(t *testing.T) {3728 t.Parallel()3729 dt := DataType{3730 Name: wordsmith.FromSingularPascalCase("Thing"),3731 }3732 p := buildExampleTodoListProject()3733 expected := `3734package main3735import (3736 "context"3737)3738func example(ctx context.Context, thingID uint64) {}3739`3740 actual := renderFunctionParamsToString(t, dt.BuildParamsForHTTPClientArchiveRequestBuildingMethod(p))3741 assert.Equal(t, expected, actual)3742 })3743 T.Run("with multiple ownership", func(t *testing.T) {3744 t.Parallel()3745 p := buildExampleTodoListProject()3746 p.DataTypes = BuildOwnershipChain("Thing", "AnotherThing", "YetAnotherThing")3747 for i := range p.DataTypes {3748 p.DataTypes[i].BelongsToUser = true3749 p.DataTypes[i].RestrictedToUser = true3750 }3751 expected := `3752package main3753import (3754 "context"3755)3756func example(ctx context.Context, thingID, anotherThingID, yetAnotherThingID uint64) {}3757`3758 actual := renderFunctionParamsToString(t, p.LastDataType().BuildParamsForHTTPClientArchiveRequestBuildingMethod(p))3759 assert.Equal(t, expected, actual)3760 })3761}3762func TestDataType_BuildArgsForHTTPClientArchiveRequestBuildingMethod(T *testing.T) {3763 T.Parallel()3764 T.Run("obligatory", func(t *testing.T) {3765 t.Parallel()3766 dt := DataType{3767 Name: wordsmith.FromSingularPascalCase("Thing"),3768 }3769 p := buildExampleTodoListProject()3770 expected := `3771package main3772import ()3773func main() {3774 exampleFunction(ctx, thingID)3775}3776`3777 actual := renderCallArgsToString(t, dt.BuildArgsForHTTPClientArchiveRequestBuildingMethod(p))3778 assert.Equal(t, expected, actual)3779 })3780 T.Run("with multiple ownership", func(t *testing.T) {3781 t.Parallel()3782 p := buildExampleTodoListProject()3783 p.DataTypes = BuildOwnershipChain("Thing", "AnotherThing", "YetAnotherThing")3784 for i := range p.DataTypes {3785 p.DataTypes[i].BelongsToUser = true3786 p.DataTypes[i].RestrictedToUser = true3787 }3788 expected := `3789package main3790import ()3791func main() {3792 exampleFunction(ctx, thingID, anotherThingID, yetAnotherThingID)3793}3794`3795 actual := renderCallArgsToString(t, p.LastDataType().BuildArgsForHTTPClientArchiveRequestBuildingMethod(p))3796 assert.Equal(t, expected, actual)3797 })3798}3799func TestDataType_BuildParamsForHTTPClientArchiveMethod(T *testing.T) {3800 T.Parallel()3801 T.Run("obligatory", func(t *testing.T) {3802 t.Parallel()3803 dt := DataType{3804 Name: wordsmith.FromSingularPascalCase("Thing"),3805 }3806 p := buildExampleTodoListProject()3807 expected := `3808package main3809import (3810 "context"3811)3812func example(ctx context.Context, thingID uint64) {}3813`3814 actual := renderFunctionParamsToString(t, dt.BuildParamsForHTTPClientArchiveMethod(p))3815 assert.Equal(t, expected, actual)3816 })3817 T.Run("with multiple ownership", func(t *testing.T) {3818 t.Parallel()3819 p := buildExampleTodoListProject()3820 p.DataTypes = BuildOwnershipChain("Thing", "AnotherThing", "YetAnotherThing")3821 for i := range p.DataTypes {3822 p.DataTypes[i].BelongsToUser = true3823 p.DataTypes[i].RestrictedToUser = true3824 }3825 expected := `3826package main3827import (3828 "context"3829)3830func example(ctx context.Context, thingID, anotherThingID, yetAnotherThingID uint64) {}3831`3832 actual := renderFunctionParamsToString(t, p.LastDataType().BuildParamsForHTTPClientArchiveMethod(p))3833 assert.Equal(t, expected, actual)3834 })3835}3836func TestDataType_buildParamsForMethodThatHandlesAnInstanceWithStructs(T *testing.T) {3837 T.Parallel()3838 T.Run("obligatory", func(t *testing.T) {3839 t.Parallel()3840 dt := DataType{3841 Name: wordsmith.FromSingularPascalCase("Thing"),3842 }3843 p := buildExampleTodoListProject()3844 expected := `3845package main3846import ()3847func example(ctx, exampleThing.ID) {}3848`3849 actual := renderFunctionParamsToString(t, dt.buildParamsForMethodThatHandlesAnInstanceWithStructs(p))3850 assert.Equal(t, expected, actual)3851 })3852 T.Run("with multiple ownership", func(t *testing.T) {3853 t.Parallel()3854 p := buildExampleTodoListProject()3855 p.DataTypes = BuildOwnershipChain("Thing", "AnotherThing", "YetAnotherThing")3856 for i := range p.DataTypes {3857 p.DataTypes[i].BelongsToUser = true3858 p.DataTypes[i].RestrictedToUser = true3859 }3860 expected := `3861package main3862import ()3863func example(ctx, exampleThing.ID, exampleAnotherThing.ID, exampleYetAnotherThing.ID) {}3864`3865 actual := renderFunctionParamsToString(t, p.LastDataType().buildParamsForMethodThatHandlesAnInstanceWithStructs(p))3866 assert.Equal(t, expected, actual)3867 })3868}3869func TestDataType_BuildArgsForHTTPClientExistenceRequestBuildingMethodTest(T *testing.T) {3870 T.Parallel()3871 T.Run("obligatory", func(t *testing.T) {3872 t.Parallel()3873 dt := DataType{3874 Name: wordsmith.FromSingularPascalCase("Thing"),3875 }3876 p := buildExampleTodoListProject()3877 expected := `3878package main3879import ()3880func main() {3881 exampleFunction(ctx, exampleThing.ID)3882}3883`3884 actual := renderCallArgsToString(t, dt.BuildArgsForHTTPClientExistenceRequestBuildingMethodTest(p))3885 assert.Equal(t, expected, actual)3886 })3887}3888func TestDataType_BuildArgsForHTTPClientExistenceMethodTest(T *testing.T) {3889 T.Parallel()3890 T.Run("obligatory", func(t *testing.T) {3891 t.Parallel()3892 dt := DataType{3893 Name: wordsmith.FromSingularPascalCase("Thing"),3894 }3895 p := buildExampleTodoListProject()3896 expected := `3897package main3898import ()3899func main() {3900 exampleFunction(ctx, exampleThing.ID)3901}3902`3903 actual := renderCallArgsToString(t, dt.BuildArgsForHTTPClientExistenceMethodTest(p))3904 assert.Equal(t, expected, actual)3905 })3906}3907func TestDataType_BuildArgsForHTTPClientRetrievalRequestBuilderMethodTest(T *testing.T) {3908 T.Parallel()3909 T.Run("obligatory", func(t *testing.T) {3910 t.Parallel()3911 dt := DataType{3912 Name: wordsmith.FromSingularPascalCase("Thing"),3913 }3914 p := buildExampleTodoListProject()3915 expected := `3916package main3917import ()3918func main() {3919 exampleFunction(ctx, exampleThing.ID)3920}3921`3922 actual := renderCallArgsToString(t, dt.BuildArgsForHTTPClientRetrievalRequestBuilderMethodTest(p))3923 assert.Equal(t, expected, actual)3924 })3925}3926func TestDataType_BuildArgsForHTTPClientArchiveRequestBuildingMethodTest(T *testing.T) {3927 T.Parallel()3928 T.Run("obligatory", func(t *testing.T) {3929 t.Parallel()3930 dt := DataType{3931 Name: wordsmith.FromSingularPascalCase("Thing"),3932 }3933 p := buildExampleTodoListProject()3934 expected := `3935package main3936import ()3937func main() {3938 exampleFunction(ctx, exampleThing.ID)3939}3940`3941 actual := renderCallArgsToString(t, dt.BuildArgsForHTTPClientArchiveRequestBuildingMethodTest(p))3942 assert.Equal(t, expected, actual)3943 })3944}3945func TestDataType_BuildArgsForHTTPClientArchiveMethodTest(T *testing.T) {3946 T.Parallel()3947 T.Run("obligatory", func(t *testing.T) {3948 t.Parallel()3949 dt := DataType{3950 Name: wordsmith.FromSingularPascalCase("Thing"),3951 }3952 p := buildExampleTodoListProject()3953 expected := `3954package main3955import ()3956func main() {3957 exampleFunction(ctx, exampleThing.ID)3958}3959`3960 actual := renderCallArgsToString(t, dt.BuildArgsForHTTPClientArchiveMethodTest(p))3961 assert.Equal(t, expected, actual)3962 })3963}3964func TestDataType_BuildArgsForHTTPClientArchiveMethodTestURLFormatCall(T *testing.T) {3965 T.Parallel()3966 T.Run("obligatory", func(t *testing.T) {3967 t.Parallel()3968 dt := DataType{3969 Name: wordsmith.FromSingularPascalCase("Thing"),3970 }3971 p := buildExampleTodoListProject()3972 expected := `3973package main3974import ()3975func main() {3976 exampleFunction(exampleThing.ID)3977}3978`3979 actual := renderCallArgsToString(t, dt.BuildArgsForHTTPClientArchiveMethodTestURLFormatCall(p))3980 assert.Equal(t, expected, actual)3981 })3982}3983func TestDataType_BuildArgsForHTTPClientMethodTest(T *testing.T) {3984 T.Parallel()3985 T.Run("obligatory", func(t *testing.T) {3986 t.Parallel()3987 dt := DataType{3988 Name: wordsmith.FromSingularPascalCase("Thing"),3989 }3990 p := buildExampleTodoListProject()3991 expected := `3992package main3993import ()3994func main() {3995 exampleFunction(ctx, exampleThing.ID)3996}3997`3998 actual := renderCallArgsToString(t, dt.BuildArgsForHTTPClientMethodTest(p))3999 assert.Equal(t, expected, actual)4000 })4001}4002func TestDataType_BuildHTTPClientCreationRequestBuildingMethodArgsForTest(T *testing.T) {4003 T.Parallel()4004 T.Run("obligatory", func(t *testing.T) {4005 t.Parallel()4006 dt := DataType{4007 Name: wordsmith.FromSingularPascalCase("Thing"),4008 }4009 p := buildExampleTodoListProject()4010 expected := `4011package main4012import ()4013func main() {4014 exampleFunction(ctx, exampleInput)4015}4016`4017 actual := renderCallArgsToString(t, dt.BuildHTTPClientCreationRequestBuildingMethodArgsForTest(p))4018 assert.Equal(t, expected, actual)4019 })4020 T.Run("with multiple ownership", func(t *testing.T) {4021 t.Parallel()4022 p := buildExampleTodoListProject()4023 p.DataTypes = BuildOwnershipChain("Thing", "AnotherThing", "YetAnotherThing")4024 for i := range p.DataTypes {4025 p.DataTypes[i].BelongsToUser = true4026 p.DataTypes[i].RestrictedToUser = true4027 }4028 expected := `4029package main4030import ()4031func main() {4032 exampleFunction(ctx, exampleThing.ID, exampleInput)4033}4034`4035 actual := renderCallArgsToString(t, p.LastDataType().BuildHTTPClientCreationRequestBuildingMethodArgsForTest(p))4036 assert.Equal(t, expected, actual)4037 })4038}4039func TestDataType_BuildHTTPClientCreationMethodArgsForTest(T *testing.T) {4040 T.Parallel()4041 T.Run("obligatory", func(t *testing.T) {4042 t.Parallel()4043 dt := DataType{4044 Name: wordsmith.FromSingularPascalCase("Thing"),4045 }4046 p := buildExampleTodoListProject()4047 expected := `4048package main4049import ()4050func main() {4051 exampleFunction(ctx, exampleInput)4052}4053`4054 actual := renderCallArgsToString(t, dt.BuildHTTPClientCreationMethodArgsForTest(p))4055 assert.Equal(t, expected, actual)4056 })4057 T.Run("with multiple ownership", func(t *testing.T) {4058 t.Parallel()4059 p := buildExampleTodoListProject()4060 p.DataTypes = BuildOwnershipChain("Thing", "AnotherThing", "YetAnotherThing")4061 for i := range p.DataTypes {4062 p.DataTypes[i].BelongsToUser = true4063 p.DataTypes[i].RestrictedToUser = true4064 }4065 expected := `4066package main4067import ()4068func main() {4069 exampleFunction(ctx, exampleThing.ID, exampleInput)4070}4071`4072 actual := renderCallArgsToString(t, p.LastDataType().BuildHTTPClientCreationMethodArgsForTest(p))4073 assert.Equal(t, expected, actual)4074 })4075}4076func TestDataType_BuildArgsForHTTPClientListRequestMethod(T *testing.T) {4077 T.Parallel()4078 T.Run("obligatory", func(t *testing.T) {4079 t.Parallel()4080 dt := DataType{4081 Name: wordsmith.FromSingularPascalCase("Thing"),4082 }4083 p := buildExampleTodoListProject()4084 expected := `4085package main4086import ()4087func main() {4088 exampleFunction(ctx, filter)4089}4090`4091 actual := renderCallArgsToString(t, dt.BuildArgsForHTTPClientListRequestMethod(p))4092 assert.Equal(t, expected, actual)4093 })4094 T.Run("with multiple ownership", func(t *testing.T) {4095 t.Parallel()4096 p := buildExampleTodoListProject()4097 p.DataTypes = BuildOwnershipChain("Thing", "AnotherThing", "YetAnotherThing")4098 for i := range p.DataTypes {4099 p.DataTypes[i].BelongsToUser = true4100 p.DataTypes[i].RestrictedToUser = true4101 }4102 expected := `4103package main4104import ()4105func main() {4106 exampleFunction(ctx, thingID, anotherThingID, filter)4107}4108`4109 actual := renderCallArgsToString(t, p.LastDataType().BuildArgsForHTTPClientListRequestMethod(p))4110 assert.Equal(t, expected, actual)4111 })4112}4113func TestDataType_BuildParamsForHTTPClientListRequestMethod(T *testing.T) {4114 T.Parallel()4115 T.Run("obligatory", func(t *testing.T) {4116 t.Parallel()4117 dt := DataType{4118 Name: wordsmith.FromSingularPascalCase("Thing"),4119 }4120 p := buildExampleTodoListProject()4121 expected := `4122package main4123import (4124 "context"4125 v1 "gitlab.com/verygoodsoftwarenotvirus/example/models/v1"4126)4127func example(ctx context.Context, filter *v1.QueryFilter) {}4128`4129 actual := renderFunctionParamsToString(t, dt.BuildParamsForHTTPClientListRequestMethod(p))4130 assert.Equal(t, expected, actual)4131 })4132 T.Run("with multiple ownership", func(t *testing.T) {4133 t.Parallel()4134 p := buildExampleTodoListProject()4135 p.DataTypes = BuildOwnershipChain("Thing", "AnotherThing", "YetAnotherThing")4136 for i := range p.DataTypes {4137 p.DataTypes[i].BelongsToUser = true4138 p.DataTypes[i].RestrictedToUser = true4139 }4140 expected := `4141package main4142import (4143 "context"4144 v1 "gitlab.com/verygoodsoftwarenotvirus/example/models/v1"4145)4146func example(ctx context.Context, thingID, anotherThingID uint64, filter *v1.QueryFilter) {}4147`4148 actual := renderFunctionParamsToString(t, p.LastDataType().BuildParamsForHTTPClientListRequestMethod(p))4149 assert.Equal(t, expected, actual)4150 })4151}4152func TestDataType_BuildParamsForHTTPClientMethodThatFetchesAList(T *testing.T) {4153 T.Parallel()4154 T.Run("obligatory", func(t *testing.T) {4155 t.Parallel()4156 dt := DataType{4157 Name: wordsmith.FromSingularPascalCase("Thing"),4158 }4159 p := buildExampleTodoListProject()4160 expected := `4161package main4162import (4163 "context"4164 v1 "gitlab.com/verygoodsoftwarenotvirus/example/models/v1"4165)4166func example(ctx context.Context, filter *v1.QueryFilter) {}4167`4168 actual := renderFunctionParamsToString(t, dt.BuildParamsForHTTPClientMethodThatFetchesAList(p))4169 assert.Equal(t, expected, actual)4170 })4171 T.Run("with multiple ownership", func(t *testing.T) {4172 t.Parallel()4173 p := buildExampleTodoListProject()4174 p.DataTypes = BuildOwnershipChain("Thing", "AnotherThing", "YetAnotherThing")4175 for i := range p.DataTypes {4176 p.DataTypes[i].BelongsToUser = true4177 p.DataTypes[i].RestrictedToUser = true4178 }4179 expected := `4180package main4181import (4182 "context"4183 v1 "gitlab.com/verygoodsoftwarenotvirus/example/models/v1"4184)4185func example(ctx context.Context, thingID, anotherThingID uint64, filter *v1.QueryFilter) {}4186`4187 actual := renderFunctionParamsToString(t, p.LastDataType().BuildParamsForHTTPClientMethodThatFetchesAList(p))4188 assert.Equal(t, expected, actual)4189 })4190}4191func TestDataType_BuildCallArgsForHTTPClientListRetrievalRequestBuildingMethodTest(T *testing.T) {4192 T.Parallel()4193 T.Run("obligatory", func(t *testing.T) {4194 t.Parallel()4195 dt := DataType{4196 Name: wordsmith.FromSingularPascalCase("Thing"),4197 }4198 p := buildExampleTodoListProject()4199 expected := `4200package main4201import ()4202func main() {4203 exampleFunction(ctx, filter)4204}4205`4206 actual := renderCallArgsToString(t, dt.BuildCallArgsForHTTPClientListRetrievalRequestBuildingMethodTest(p))4207 assert.Equal(t, expected, actual)4208 })4209 T.Run("with multiple ownership", func(t *testing.T) {4210 t.Parallel()4211 p := buildExampleTodoListProject()4212 p.DataTypes = BuildOwnershipChain("Thing", "AnotherThing", "YetAnotherThing")4213 for i := range p.DataTypes {4214 p.DataTypes[i].BelongsToUser = true4215 p.DataTypes[i].RestrictedToUser = true4216 }4217 expected := `4218package main4219import ()4220func main() {4221 exampleFunction(ctx, exampleThing.ID, exampleAnotherThing.ID, filter)4222}4223`4224 actual := renderCallArgsToString(t, p.LastDataType().BuildCallArgsForHTTPClientListRetrievalRequestBuildingMethodTest(p))4225 assert.Equal(t, expected, actual)4226 })4227}4228func TestDataType_BuildCallArgsForHTTPClientListRetrievalMethodTest(T *testing.T) {4229 T.Parallel()4230 T.Run("obligatory", func(t *testing.T) {4231 t.Parallel()4232 dt := DataType{4233 Name: wordsmith.FromSingularPascalCase("Thing"),4234 }4235 p := buildExampleTodoListProject()4236 expected := `4237package main4238import ()4239func main() {4240 exampleFunction(ctx, filter)4241}4242`4243 actual := renderCallArgsToString(t, dt.BuildCallArgsForHTTPClientListRetrievalMethodTest(p))4244 assert.Equal(t, expected, actual)4245 })4246 T.Run("with multiple ownership", func(t *testing.T) {4247 t.Parallel()4248 p := buildExampleTodoListProject()4249 p.DataTypes = BuildOwnershipChain("Thing", "AnotherThing", "YetAnotherThing")4250 for i := range p.DataTypes {4251 p.DataTypes[i].BelongsToUser = true4252 p.DataTypes[i].RestrictedToUser = true4253 }4254 expected := `4255package main4256import ()4257func main() {4258 exampleFunction(ctx, exampleThing.ID, exampleAnotherThing.ID, filter)4259}4260`4261 actual := renderCallArgsToString(t, p.LastDataType().BuildCallArgsForHTTPClientListRetrievalMethodTest(p))4262 assert.Equal(t, expected, actual)4263 })4264}4265func TestDataType_BuildCallArgsForHTTPClientUpdateRequestBuildingMethodTest(T *testing.T) {4266 T.Parallel()4267 T.Run("obligatory", func(t *testing.T) {4268 t.Parallel()4269 dt := DataType{4270 Name: wordsmith.FromSingularPascalCase("Thing"),4271 }4272 p := buildExampleTodoListProject()4273 expected := `4274package main4275import ()4276func main() {4277 exampleFunction(ctx, exampleThing)4278}4279`4280 actual := renderCallArgsToString(t, dt.BuildCallArgsForHTTPClientUpdateRequestBuildingMethodTest(p))4281 assert.Equal(t, expected, actual)4282 })4283 T.Run("with multiple ownership", func(t *testing.T) {4284 t.Parallel()4285 p := buildExampleTodoListProject()4286 p.DataTypes = BuildOwnershipChain("Thing", "AnotherThing", "YetAnotherThing")4287 for i := range p.DataTypes {4288 p.DataTypes[i].BelongsToUser = true4289 p.DataTypes[i].RestrictedToUser = true4290 }4291 expected := `4292package main4293import ()4294func main() {4295 exampleFunction(ctx, exampleThing.ID, exampleYetAnotherThing)4296}4297`4298 actual := renderCallArgsToString(t, p.LastDataType().BuildCallArgsForHTTPClientUpdateRequestBuildingMethodTest(p))4299 assert.Equal(t, expected, actual)4300 })4301}4302func TestDataType_BuildCallArgsForHTTPClientUpdateMethodTest(T *testing.T) {4303 T.Parallel()4304 T.Run("obligatory", func(t *testing.T) {4305 t.Parallel()4306 dt := DataType{4307 Name: wordsmith.FromSingularPascalCase("Thing"),4308 }4309 p := buildExampleTodoListProject()4310 expected := `4311package main4312import ()4313func main() {4314 exampleFunction(ctx, exampleThing)4315}4316`4317 actual := renderCallArgsToString(t, dt.BuildCallArgsForHTTPClientUpdateMethodTest(p))4318 assert.Equal(t, expected, actual)4319 })4320 T.Run("with multiple ownership", func(t *testing.T) {4321 t.Parallel()4322 p := buildExampleTodoListProject()4323 p.DataTypes = BuildOwnershipChain("Thing", "AnotherThing", "YetAnotherThing")4324 for i := range p.DataTypes {4325 p.DataTypes[i].BelongsToUser = true4326 p.DataTypes[i].RestrictedToUser = true4327 }4328 expected := `4329package main4330import ()4331func main() {4332 exampleFunction(ctx, exampleThing.ID, exampleYetAnotherThing)4333}4334`4335 actual := renderCallArgsToString(t, p.LastDataType().BuildCallArgsForHTTPClientUpdateMethodTest(p))4336 assert.Equal(t, expected, actual)4337 })4338}4339func TestDataType_buildRequisiteFakeVarDecs(T *testing.T) {4340 T.Parallel()4341 T.Run("creating context", func(t *testing.T) {4342 t.Parallel()4343 dt := DataType{4344 Name: wordsmith.FromSingularPascalCase("Thing"),4345 }4346 p := buildExampleTodoListProject()4347 expected := `4348package main4349import (4350 "context"4351 fake "gitlab.com/verygoodsoftwarenotvirus/example/models/v1/fake"4352)4353func main() {4354 ctx := context.Background()4355 exampleThing := fake.BuildFakeThing()4356}4357`4358 actual := renderVariableDeclarationsToString(t, dt.buildRequisiteFakeVarDecs(p, true))4359 assert.Equal(t, expected, actual)4360 })4361 T.Run("without creating context", func(t *testing.T) {4362 t.Parallel()4363 dt := DataType{4364 Name: wordsmith.FromSingularPascalCase("Thing"),4365 }4366 p := buildExampleTodoListProject()4367 expected := `4368package main4369import (4370 fake "gitlab.com/verygoodsoftwarenotvirus/example/models/v1/fake"4371)4372func main() {4373 exampleThing := fake.BuildFakeThing()4374}4375`4376 actual := renderVariableDeclarationsToString(t, dt.buildRequisiteFakeVarDecs(p, false))4377 assert.Equal(t, expected, actual)4378 })4379 T.Run("with multiple ownership", func(t *testing.T) {4380 t.Parallel()4381 p := buildExampleTodoListProject()4382 p.DataTypes = BuildOwnershipChain("Thing", "AnotherThing", "YetAnotherThing")4383 for i := range p.DataTypes {4384 p.DataTypes[i].BelongsToUser = true4385 p.DataTypes[i].RestrictedToUser = true4386 }4387 expected := `4388package main4389import (4390 "context"4391 fake "gitlab.com/verygoodsoftwarenotvirus/example/models/v1/fake"4392)4393func main() {4394 ctx := context.Background()4395 exampleUser := fake.BuildFakeUser()4396 exampleThing := fake.BuildFakeThing()4397 exampleThing.BelongsToUser = exampleUser.ID4398 exampleAnotherThing := fake.BuildFakeAnotherThing()4399 exampleAnotherThing.BelongsToUser = exampleUser.ID4400 exampleAnotherThing.BelongsToThing = exampleThing.ID4401 exampleYetAnotherThing := fake.BuildFakeYetAnotherThing()4402 exampleYetAnotherThing.BelongsToUser = exampleUser.ID4403 exampleYetAnotherThing.BelongsToAnotherThing = exampleAnotherThing.ID4404}4405`4406 actual := renderVariableDeclarationsToString(t, p.LastDataType().buildRequisiteFakeVarDecs(p, true))4407 assert.Equal(t, expected, actual)4408 })4409}4410func TestDataType_buildRequisiteFakeVarDecForModifierFuncs(T *testing.T) {4411 T.Parallel()4412 T.Run("creating context", func(t *testing.T) {4413 t.Parallel()4414 dt := DataType{4415 Name: wordsmith.FromSingularPascalCase("Thing"),4416 }4417 p := buildExampleTodoListProject()4418 expected := `4419package main4420import (4421 "context"4422 fake "gitlab.com/verygoodsoftwarenotvirus/example/models/v1/fake"4423)4424func main() {4425 ctx := context.Background()4426 exampleThing := fake.BuildFakeThing()4427}4428`4429 actual := renderVariableDeclarationsToString(t, dt.buildRequisiteFakeVarDecForModifierFuncs(p, true))4430 assert.Equal(t, expected, actual)4431 })4432 T.Run("without creating context", func(t *testing.T) {4433 t.Parallel()4434 dt := DataType{4435 Name: wordsmith.FromSingularPascalCase("Thing"),4436 }4437 p := buildExampleTodoListProject()4438 expected := `4439package main4440import (4441 fake "gitlab.com/verygoodsoftwarenotvirus/example/models/v1/fake"4442)4443func main() {4444 exampleThing := fake.BuildFakeThing()4445}4446`4447 actual := renderVariableDeclarationsToString(t, dt.buildRequisiteFakeVarDecForModifierFuncs(p, false))4448 assert.Equal(t, expected, actual)4449 })4450 T.Run("with multiple ownership", func(t *testing.T) {4451 t.Parallel()4452 p := buildExampleTodoListProject()4453 p.DataTypes = BuildOwnershipChain("Thing", "AnotherThing", "YetAnotherThing")4454 for i := range p.DataTypes {4455 p.DataTypes[i].BelongsToUser = true4456 p.DataTypes[i].RestrictedToUser = true4457 }4458 expected := `4459package main4460import (4461 "context"4462 fake "gitlab.com/verygoodsoftwarenotvirus/example/models/v1/fake"4463)4464func main() {4465 ctx := context.Background()4466 exampleUser := fake.BuildFakeUser()4467 exampleYetAnotherThing := fake.BuildFakeYetAnotherThing()4468 exampleYetAnotherThing.BelongsToUser = exampleUser.ID4469 exampleYetAnotherThing.BelongsToAnotherThing = exampleAnotherThing.ID4470}4471`4472 actual := renderVariableDeclarationsToString(t, p.LastDataType().buildRequisiteFakeVarDecForModifierFuncs(p, true))4473 assert.Equal(t, expected, actual)4474 })4475}4476func TestDataType_BuildRequisiteFakeVarsForDBClientExistenceMethodTest(T *testing.T) {4477 T.Parallel()4478 T.Run("obligatory", func(t *testing.T) {4479 t.Parallel()4480 dt := DataType{4481 Name: wordsmith.FromSingularPascalCase("Thing"),4482 }4483 p := buildExampleTodoListProject()4484 expected := `4485package main4486import (4487 "context"4488 fake "gitlab.com/verygoodsoftwarenotvirus/example/models/v1/fake"4489)4490func main() {4491 ctx := context.Background()4492 exampleThing := fake.BuildFakeThing()4493}4494`4495 actual := renderVariableDeclarationsToString(t, dt.BuildRequisiteFakeVarsForDBClientExistenceMethodTest(p))4496 assert.Equal(t, expected, actual)4497 })4498}4499func TestDataType_BuildRequisiteFakeVarsForDBClientRetrievalMethodTest(T *testing.T) {4500 T.Parallel()4501 T.Run("obligatory", func(t *testing.T) {4502 t.Parallel()4503 dt := DataType{4504 Name: wordsmith.FromSingularPascalCase("Thing"),4505 }4506 p := buildExampleTodoListProject()4507 expected := `4508package main4509import (4510 fake "gitlab.com/verygoodsoftwarenotvirus/example/models/v1/fake"4511)4512func main() {4513 exampleThing := fake.BuildFakeThing()4514}4515`4516 actual := renderVariableDeclarationsToString(t, dt.BuildRequisiteFakeVarsForDBClientRetrievalMethodTest(p))4517 assert.Equal(t, expected, actual)4518 })4519}4520func TestDataType_BuildRequisiteFakeVarsForDBClientCreateMethodTest(T *testing.T) {4521 T.Parallel()4522 T.Run("obligatory", func(t *testing.T) {4523 t.Parallel()4524 dt := DataType{4525 Name: wordsmith.FromSingularPascalCase("Thing"),4526 }4527 p := buildExampleTodoListProject()4528 expected := `4529package main4530import (4531 "context"4532 fake "gitlab.com/verygoodsoftwarenotvirus/example/models/v1/fake"4533)4534func main() {4535 ctx := context.Background()4536 exampleThing := fake.BuildFakeThing()4537}4538`4539 actual := renderVariableDeclarationsToString(t, dt.BuildRequisiteFakeVarsForDBClientCreateMethodTest(p))4540 assert.Equal(t, expected, actual)4541 })4542 T.Run("with multiple ownership", func(t *testing.T) {4543 t.Parallel()4544 p := buildExampleTodoListProject()4545 p.DataTypes = BuildOwnershipChain("Thing", "AnotherThing", "YetAnotherThing")4546 for i := range p.DataTypes {4547 p.DataTypes[i].BelongsToUser = true4548 p.DataTypes[i].RestrictedToUser = true4549 }4550 expected := `4551package main4552import (4553 "context"4554 fake "gitlab.com/verygoodsoftwarenotvirus/example/models/v1/fake"4555)4556func main() {4557 ctx := context.Background()4558 exampleUser := fake.BuildFakeUser()4559 exampleYetAnotherThing := fake.BuildFakeYetAnotherThing()4560 exampleYetAnotherThing.BelongsToUser = exampleUser.ID4561}4562`4563 actual := renderVariableDeclarationsToString(t, p.LastDataType().BuildRequisiteFakeVarsForDBClientCreateMethodTest(p))4564 assert.Equal(t, expected, actual)4565 })4566}4567func TestDataType_BuildRequisiteFakeVarsForDBClientArchiveMethodTest(T *testing.T) {4568 T.Parallel()4569 T.Run("obligatory", func(t *testing.T) {4570 t.Parallel()4571 dt := DataType{4572 Name: wordsmith.FromSingularPascalCase("Thing"),4573 }4574 p := buildExampleTodoListProject()4575 expected := `4576package main4577import (4578 "context"4579 fake "gitlab.com/verygoodsoftwarenotvirus/example/models/v1/fake"4580)4581func main() {4582 ctx := context.Background()4583 var expected error4584 exampleThing := fake.BuildFakeThing()4585}4586`4587 actual := renderVariableDeclarationsToString(t, dt.BuildRequisiteFakeVarsForDBClientArchiveMethodTest(p))4588 assert.Equal(t, expected, actual)4589 })4590 T.Run("with multiple ownership", func(t *testing.T) {4591 t.Parallel()4592 p := buildExampleTodoListProject()4593 p.DataTypes = BuildOwnershipChain("Thing", "AnotherThing", "YetAnotherThing")4594 for i := range p.DataTypes {4595 p.DataTypes[i].BelongsToUser = true4596 p.DataTypes[i].RestrictedToUser = true4597 }4598 expected := `4599package main4600import (4601 "context"4602 fake "gitlab.com/verygoodsoftwarenotvirus/example/models/v1/fake"4603)4604func main() {4605 ctx := context.Background()4606 var expected error4607 exampleUser := fake.BuildFakeUser()4608 exampleYetAnotherThing := fake.BuildFakeYetAnotherThing()4609 exampleYetAnotherThing.BelongsToUser = exampleUser.ID4610}4611`4612 actual := renderVariableDeclarationsToString(t, p.LastDataType().BuildRequisiteFakeVarsForDBClientArchiveMethodTest(p))4613 assert.Equal(t, expected, actual)4614 })4615}4616func TestDataType_BuildRequisiteFakeVarDecsForDBQuerierRetrievalMethodTest(T *testing.T) {4617 T.Parallel()4618 T.Run("obligatory", func(t *testing.T) {4619 t.Parallel()4620 dt := DataType{4621 Name: wordsmith.FromSingularPascalCase("Thing"),4622 }4623 p := buildExampleTodoListProject()4624 expected := `4625package main4626import (4627 fake "gitlab.com/verygoodsoftwarenotvirus/example/models/v1/fake"4628)4629func main() {4630 exampleThing := fake.BuildFakeThing()4631}4632`4633 actual := renderVariableDeclarationsToString(t, dt.BuildRequisiteFakeVarDecsForDBQuerierRetrievalMethodTest(p))4634 assert.Equal(t, expected, actual)4635 })4636 T.Run("with multiple ownership", func(t *testing.T) {4637 t.Parallel()4638 p := buildExampleTodoListProject()4639 p.DataTypes = BuildOwnershipChain("Thing", "AnotherThing", "YetAnotherThing")4640 for i := range p.DataTypes {4641 p.DataTypes[i].BelongsToUser = true4642 p.DataTypes[i].RestrictedToUser = true4643 }4644 expected := `4645package main4646import (4647 fake "gitlab.com/verygoodsoftwarenotvirus/example/models/v1/fake"4648)4649func main() {4650 exampleThing := fake.BuildFakeThing()4651 exampleThing.BelongsToUser = exampleUser.ID4652 exampleAnotherThing := fake.BuildFakeAnotherThing()4653 exampleAnotherThing.BelongsToThing = exampleThing.ID4654 exampleAnotherThing.BelongsToUser = exampleUser.ID4655 exampleYetAnotherThing := fake.BuildFakeYetAnotherThing()4656 exampleYetAnotherThing.BelongsToAnotherThing = exampleAnotherThing.ID4657 exampleYetAnotherThing.BelongsToUser = exampleUser.ID4658}4659`4660 actual := renderVariableDeclarationsToString(t, p.LastDataType().BuildRequisiteFakeVarDecsForDBQuerierRetrievalMethodTest(p))4661 assert.Equal(t, expected, actual)4662 })4663}4664func TestDataType_buildRequisiteFakeVarDecsForListFunction(T *testing.T) {4665 T.Parallel()4666 T.Run("obligatory", func(t *testing.T) {4667 t.Parallel()4668 dt := DataType{4669 Name: wordsmith.FromSingularPascalCase("Thing"),4670 }4671 p := buildExampleTodoListProject()4672 expected := `4673package main4674import ()4675func main() {}4676`4677 actual := renderVariableDeclarationsToString(t, dt.buildRequisiteFakeVarDecsForListFunction(p))4678 assert.Equal(t, expected, actual)4679 })4680 T.Run("with multiple ownership", func(t *testing.T) {4681 t.Parallel()4682 p := buildExampleTodoListProject()4683 p.DataTypes = BuildOwnershipChain("Thing", "AnotherThing", "YetAnotherThing")4684 for i := range p.DataTypes {4685 if i != len(p.DataTypes)-1 {4686 p.DataTypes[i].BelongsToUser = true4687 p.DataTypes[i].RestrictedToUser = true4688 }4689 }4690 expected := `4691package main4692import (4693 fake "gitlab.com/verygoodsoftwarenotvirus/example/models/v1/fake"4694)4695func main() {4696 exampleUser := fake.BuildFakeUser()4697 exampleThing := fake.BuildFakeThing()4698 exampleAnotherThing := fake.BuildFakeAnotherThing()4699}4700`4701 actual := renderVariableDeclarationsToString(t, p.LastDataType().buildRequisiteFakeVarDecsForListFunction(p))4702 assert.Equal(t, expected, actual)4703 })4704}4705func TestDataType_BuildRequisiteFakeVarsForDBClientListRetrievalMethodTest(T *testing.T) {4706 T.Parallel()4707 T.Run("obligatory", func(t *testing.T) {4708 t.Parallel()4709 p := buildExampleTodoListProject()4710 p.DataTypes = BuildOwnershipChain("Thing", "AnotherThing", "YetAnotherThing")4711 expected := `4712package main4713import (4714 fake "gitlab.com/verygoodsoftwarenotvirus/example/models/v1/fake"4715)4716func main() {4717 exampleThing := fake.BuildFakeThing()4718 exampleAnotherThing := fake.BuildFakeAnotherThing()4719}4720`4721 actual := renderVariableDeclarationsToString(t, p.LastDataType().BuildRequisiteFakeVarsForDBClientListRetrievalMethodTest(p))4722 assert.Equal(t, expected, actual)4723 })4724}4725func TestDataType_BuildRequisiteFakeVarsForDBQuerierListRetrievalMethodTest(T *testing.T) {4726 T.Parallel()4727 T.Run("with filter", func(t *testing.T) {4728 t.Parallel()4729 p := buildExampleTodoListProject()4730 p.DataTypes = BuildOwnershipChain("Thing", "AnotherThing", "YetAnotherThing")4731 expected := `4732package main4733import (4734 fake "gitlab.com/verygoodsoftwarenotvirus/example/models/v1/fake"4735)4736func main() {4737 exampleThing := fake.BuildFakeThing()4738 exampleAnotherThing := fake.BuildFakeAnotherThing()4739 exampleAnotherThing.BelongsToThing = exampleThing.ID4740 filter := fake.BuildFleshedOutQueryFilter()4741}4742`4743 actual := renderVariableDeclarationsToString(t, p.LastDataType().BuildRequisiteFakeVarsForDBQuerierListRetrievalMethodTest(p, true))4744 assert.Equal(t, expected, actual)4745 })4746 T.Run("without filter", func(t *testing.T) {4747 t.Parallel()4748 p := buildExampleTodoListProject()4749 p.DataTypes = BuildOwnershipChain("Thing", "AnotherThing", "YetAnotherThing")4750 expected := `4751package main4752import (4753 fake "gitlab.com/verygoodsoftwarenotvirus/example/models/v1/fake"4754)4755func main() {4756 exampleThing := fake.BuildFakeThing()4757 exampleAnotherThing := fake.BuildFakeAnotherThing()4758 exampleAnotherThing.BelongsToThing = exampleThing.ID4759}4760`4761 actual := renderVariableDeclarationsToString(t, p.LastDataType().BuildRequisiteFakeVarsForDBQuerierListRetrievalMethodTest(p, false))4762 assert.Equal(t, expected, actual)4763 })4764 T.Run("with multiple ownership", func(t *testing.T) {4765 t.Parallel()4766 p := buildExampleTodoListProject()4767 p.DataTypes = BuildOwnershipChain("Thing", "AnotherThing", "YetAnotherThing")4768 for i := range p.DataTypes {4769 p.DataTypes[i].BelongsToUser = true4770 p.DataTypes[i].RestrictedToUser = true4771 }4772 expected := `4773package main4774import (4775 fake "gitlab.com/verygoodsoftwarenotvirus/example/models/v1/fake"4776)4777func main() {4778 exampleUser := fake.BuildFakeUser()4779 exampleThing := fake.BuildFakeThing()4780 exampleThing.BelongsToUser = exampleUser.ID4781 exampleAnotherThing := fake.BuildFakeAnotherThing()4782 exampleAnotherThing.BelongsToUser = exampleUser.ID4783 exampleAnotherThing.BelongsToThing = exampleThing.ID4784 filter := fake.BuildFleshedOutQueryFilter()4785}4786`4787 actual := renderVariableDeclarationsToString(t, p.LastDataType().BuildRequisiteFakeVarsForDBQuerierListRetrievalMethodTest(p, true))4788 assert.Equal(t, expected, actual)4789 })4790}4791func TestDataType_buildRequisiteFakeVarCallArgsForCreation(T *testing.T) {4792 T.Parallel()4793 T.Run("obligatory", func(t *testing.T) {4794 t.Parallel()4795 p := buildExampleTodoListProject()4796 p.DataTypes = BuildOwnershipChain("Thing", "AnotherThing", "YetAnotherThing")4797 expected := `4798package main4799import ()4800func main() {4801 exampleThing.ID4802 exampleAnotherThing.ID4803 exampleYetAnotherThing.ID4804}4805`4806 actual := renderVariableDeclarationsToString(t, p.LastDataType().buildRequisiteFakeVarCallArgsForCreation(p))4807 assert.Equal(t, expected, actual)4808 })4809 T.Run("with multiple ownership", func(t *testing.T) {4810 t.Parallel()4811 p := buildExampleTodoListProject()4812 p.DataTypes = BuildOwnershipChain("Thing", "AnotherThing", "YetAnotherThing")4813 for i := range p.DataTypes {4814 p.DataTypes[i].BelongsToUser = true4815 p.DataTypes[i].RestrictedToUser = true4816 }4817 expected := `4818package main4819import ()4820func main() {4821 exampleThing.ID4822 exampleAnotherThing.ID4823 exampleYetAnotherThing.ID4824 exampleYetAnotherThing.BelongsToUser4825}4826`4827 actual := renderVariableDeclarationsToString(t, p.LastDataType().buildRequisiteFakeVarCallArgsForCreation(p))4828 assert.Equal(t, expected, actual)4829 })4830}4831func TestDataType_buildRequisiteFakeVarCallArgs(T *testing.T) {4832 T.Parallel()4833 T.Run("obligatory", func(t *testing.T) {4834 t.Parallel()4835 p := buildExampleTodoListProject()4836 p.DataTypes = BuildOwnershipChain("Thing", "AnotherThing", "YetAnotherThing")4837 expected := `4838package main4839import ()4840func main() {4841 exampleFunction(exampleThing.ID, exampleAnotherThing.ID, exampleYetAnotherThing.ID)4842}4843`4844 actual := renderCallArgsToString(t, p.LastDataType().buildRequisiteFakeVarCallArgs(p))4845 assert.Equal(t, expected, actual)4846 })4847 T.Run("type restricted to user", func(t *testing.T) {4848 t.Parallel()4849 p := buildExampleTodoListProject()4850 p.DataTypes = BuildOwnershipChain("Thing", "AnotherThing", "YetAnotherThing")4851 for i := range p.DataTypes {4852 p.DataTypes[i].BelongsToUser = true4853 p.DataTypes[i].RestrictedToUser = true4854 }4855 expected := `4856package main4857import ()4858func main() {4859 exampleFunction(exampleThing.ID, exampleAnotherThing.ID, exampleYetAnotherThing.ID, exampleYetAnotherThing.BelongsToUser)4860}4861`4862 actual := renderCallArgsToString(t, p.LastDataType().buildRequisiteFakeVarCallArgs(p))4863 assert.Equal(t, expected, actual)4864 })4865 T.Run("belonging to type restricted to user", func(t *testing.T) {4866 t.Parallel()4867 p := buildExampleTodoListProject()4868 p.DataTypes = BuildOwnershipChain("Thing", "AnotherThing", "YetAnotherThing")4869 p.DataTypes[0].BelongsToUser = true4870 p.DataTypes[0].RestrictedToUser = true4871 expected := `4872package main4873import ()4874func main() {4875 exampleFunction(exampleThing.ID, exampleAnotherThing.ID, exampleYetAnotherThing.ID, exampleUser.ID)4876}4877`4878 actual := renderCallArgsToString(t, p.LastDataType().buildRequisiteFakeVarCallArgs(p))4879 assert.Equal(t, expected, actual)4880 })4881}4882func TestDataType_buildRequisiteFakeVarCallArgsForServicesThatUseExampleUser(T *testing.T) {4883 T.Parallel()4884 T.Run("obligatory", func(t *testing.T) {4885 t.Parallel()4886 p := buildExampleTodoListProject()4887 p.DataTypes = BuildOwnershipChain("Thing", "AnotherThing", "YetAnotherThing")4888 expected := `4889package main4890import ()4891func main() {4892 exampleFunction(exampleThing.ID, exampleAnotherThing.ID, exampleYetAnotherThing.ID)4893}4894`4895 actual := renderCallArgsToString(t, p.LastDataType().buildRequisiteFakeVarCallArgsForServicesThatUseExampleUser(p))4896 assert.Equal(t, expected, actual)4897 })4898 T.Run("with user restriction", func(t *testing.T) {4899 t.Parallel()4900 p := buildExampleTodoListProject()4901 p.DataTypes = BuildOwnershipChain("Thing", "AnotherThing", "YetAnotherThing")4902 p.DataTypes[0].BelongsToUser = true4903 p.DataTypes[0].RestrictedToUser = true4904 expected := `4905package main4906import ()4907func main() {4908 exampleFunction(exampleThing.ID, exampleAnotherThing.ID, exampleYetAnotherThing.ID, exampleUser.ID)4909}4910`4911 actual := renderCallArgsToString(t, p.LastDataType().buildRequisiteFakeVarCallArgsForServicesThatUseExampleUser(p))4912 assert.Equal(t, expected, actual)4913 })4914}4915func TestDataType_BuildRequisiteFakeVarCallArgsForServiceExistenceHandlerTest(T *testing.T) {4916 T.Parallel()4917 T.Run("obligatory", func(t *testing.T) {4918 t.Parallel()4919 p := buildExampleTodoListProject()4920 p.DataTypes = BuildOwnershipChain("Thing", "AnotherThing", "YetAnotherThing")4921 expected := `4922package main4923import ()4924func main() {4925 exampleFunction(exampleThing.ID, exampleAnotherThing.ID, exampleYetAnotherThing.ID)4926}4927`4928 actual := renderCallArgsToString(t, p.LastDataType().BuildRequisiteFakeVarCallArgsForServiceExistenceHandlerTest(p))4929 assert.Equal(t, expected, actual)4930 })4931}4932func TestDataType_BuildRequisiteFakeVarCallArgsForServiceReadHandlerTest(T *testing.T) {4933 T.Parallel()4934 T.Run("obligatory", func(t *testing.T) {4935 t.Parallel()4936 p := buildExampleTodoListProject()4937 p.DataTypes = BuildOwnershipChain("Thing", "AnotherThing", "YetAnotherThing")4938 expected := `4939package main4940import ()4941func main() {4942 exampleFunction(exampleThing.ID, exampleAnotherThing.ID, exampleYetAnotherThing.ID)4943}4944`4945 actual := renderCallArgsToString(t, p.LastDataType().BuildRequisiteFakeVarCallArgsForServiceReadHandlerTest(p))4946 assert.Equal(t, expected, actual)4947 })4948}4949func TestDataType_BuildRequisiteFakeVarCallArgsForServiceCreateHandlerTest(T *testing.T) {4950 T.Parallel()4951 T.Run("obligatory", func(t *testing.T) {4952 t.Parallel()4953 p := buildExampleTodoListProject()4954 p.DataTypes = BuildOwnershipChain("Thing", "AnotherThing", "YetAnotherThing")4955 expected := `4956package main4957import ()4958func main() {4959 exampleFunction(exampleThing.ID, exampleAnotherThing.ID, exampleYetAnotherThing.ID)4960}4961`4962 actual := renderCallArgsToString(t, p.LastDataType().BuildRequisiteFakeVarCallArgsForServiceCreateHandlerTest(p))4963 assert.Equal(t, expected, actual)4964 })4965}4966func TestDataType_BuildRequisiteFakeVarCallArgsForServiceUpdateHandlerTest(T *testing.T) {4967 T.Parallel()4968 T.Run("obligatory", func(t *testing.T) {4969 t.Parallel()4970 p := buildExampleTodoListProject()4971 p.DataTypes = BuildOwnershipChain("Thing", "AnotherThing", "YetAnotherThing")4972 expected := `4973package main4974import ()4975func main() {4976 exampleFunction(exampleThing.ID, exampleAnotherThing.ID, exampleYetAnotherThing.ID)4977}4978`4979 actual := renderCallArgsToString(t, p.LastDataType().BuildRequisiteFakeVarCallArgsForServiceUpdateHandlerTest(p))4980 assert.Equal(t, expected, actual)4981 })4982}4983func TestDataType_BuildRequisiteFakeVarCallArgsForServiceArchiveHandlerTest(T *testing.T) {4984 T.Parallel()4985 T.Run("obligatory", func(t *testing.T) {4986 t.Parallel()4987 dt := DataType{4988 Name: wordsmith.FromSingularPascalCase("Thing"),4989 }4990 expected := `4991package main4992import ()4993func main() {4994 exampleFunction(exampleThing.ID)4995}4996`4997 actual := renderCallArgsToString(t, dt.BuildRequisiteFakeVarCallArgsForServiceArchiveHandlerTest())4998 assert.Equal(t, expected, actual)4999 })5000 T.Run("with multiple ownership", func(t *testing.T) {5001 t.Parallel()5002 dt := DataType{5003 BelongsToStruct: wordsmith.FromSingularPascalCase("Thing"),5004 Name: wordsmith.FromSingularPascalCase("AnotherThing"),5005 BelongsToUser: true,5006 }5007 expected := `5008package main5009import ()5010func main() {5011 exampleFunction(exampleThing.ID, exampleAnotherThing.ID, exampleUser.ID)5012}5013`5014 actual := renderCallArgsToString(t, dt.BuildRequisiteFakeVarCallArgsForServiceArchiveHandlerTest())5015 assert.Equal(t, expected, actual)5016 })5017}5018func TestDataType_BuildRequisiteFakeVarCallArgsForDBClientExistenceMethodTest(T *testing.T) {5019 T.Parallel()5020 T.Run("obligatory", func(t *testing.T) {5021 t.Parallel()5022 p := buildExampleTodoListProject()5023 p.DataTypes = BuildOwnershipChain("Thing", "AnotherThing", "YetAnotherThing")5024 expected := `5025package main5026import ()5027func main() {5028 exampleFunction(exampleThing.ID, exampleAnotherThing.ID, exampleYetAnotherThing.ID)5029}5030`5031 actual := renderCallArgsToString(t, p.LastDataType().BuildRequisiteFakeVarCallArgsForDBClientExistenceMethodTest(p))5032 assert.Equal(t, expected, actual)5033 })5034}5035func TestDataType_BuildRequisiteFakeVarCallArgsForDBClientRetrievalMethodTest(T *testing.T) {5036 T.Parallel()5037 T.Run("obligatory", func(t *testing.T) {5038 t.Parallel()5039 p := buildExampleTodoListProject()5040 p.DataTypes = BuildOwnershipChain("Thing", "AnotherThing", "YetAnotherThing")5041 expected := `5042package main5043import ()5044func main() {5045 exampleFunction(exampleThing.ID, exampleAnotherThing.ID, exampleYetAnotherThing.ID)5046}5047`5048 actual := renderCallArgsToString(t, p.LastDataType().BuildRequisiteFakeVarCallArgsForDBClientRetrievalMethodTest(p))5049 assert.Equal(t, expected, actual)5050 })5051}5052func TestDataType_BuildRequisiteFakeVarCallArgsForDBClientArchiveMethodTest(T *testing.T) {5053 T.Parallel()5054 T.Run("obligatory", func(t *testing.T) {5055 t.Parallel()5056 dt := DataType{5057 Name: wordsmith.FromSingularPascalCase("Thing"),5058 }5059 expected := `5060package main5061import ()5062func main() {5063 exampleFunction(exampleThing.ID)5064}5065`5066 actual := renderCallArgsToString(t, dt.BuildRequisiteFakeVarCallArgsForDBClientArchiveMethodTest())5067 assert.Equal(t, expected, actual)5068 })5069 T.Run("with multiple ownership", func(t *testing.T) {5070 t.Parallel()5071 dt := DataType{5072 BelongsToStruct: wordsmith.FromSingularPascalCase("Thing"),5073 Name: wordsmith.FromSingularPascalCase("AnotherThing"),5074 BelongsToUser: true,5075 }5076 expected := `5077package main5078import ()5079func main() {5080 exampleFunction(exampleAnotherThing.BelongsToThing, exampleAnotherThing.ID, exampleAnotherThing.BelongsToUser)5081}5082`5083 actual := renderCallArgsToString(t, dt.BuildRequisiteFakeVarCallArgsForDBClientArchiveMethodTest())5084 assert.Equal(t, expected, actual)5085 })5086}5087func TestDataType_BuildExpectedQueryArgsForDBQueriersListRetrievalMethodTest(T *testing.T) {5088 T.Parallel()5089 T.Run("obligatory", func(t *testing.T) {5090 t.Parallel()5091 p := buildExampleTodoListProject()5092 p.DataTypes = BuildOwnershipChain("Thing", "AnotherThing", "YetAnotherThing")5093 expected := `5094package main5095import ()5096func main() {5097 exampleFunction(exampleThing.ID, exampleAnotherThing.ID)5098}5099`5100 actual := renderCallArgsToString(t, p.LastDataType().BuildExpectedQueryArgsForDBQueriersListRetrievalMethodTest(p))5101 assert.Equal(t, expected, actual)5102 })5103 T.Run("with user restriction", func(t *testing.T) {5104 t.Parallel()5105 p := buildExampleTodoListProject()5106 p.DataTypes = BuildOwnershipChain("Thing", "AnotherThing", "YetAnotherThing")5107 p.DataTypes[2].BelongsToUser = true5108 p.DataTypes[2].RestrictedToUser = true5109 expected := `5110package main5111import ()5112func main() {5113 exampleFunction(exampleThing.ID, exampleAnotherThing.ID, exampleUser.ID)5114}5115`5116 actual := renderCallArgsToString(t, p.LastDataType().BuildExpectedQueryArgsForDBQueriersListRetrievalMethodTest(p))5117 assert.Equal(t, expected, actual)5118 })5119}5120func TestDataType_BuildRequisiteFakeVarCallArgsForDBQueriersListRetrievalMethodTest(T *testing.T) {5121 T.Parallel()5122 T.Run("obligatory", func(t *testing.T) {5123 t.Parallel()5124 dt := DataType{5125 Name: wordsmith.FromSingularPascalCase("Thing"),5126 }5127 p := buildExampleTodoListProject()5128 expected := `5129package main5130import ()5131func main() {5132 exampleFunction(ctx, filter)5133}5134`5135 actual := renderCallArgsToString(t, dt.BuildRequisiteFakeVarCallArgsForDBQueriersListRetrievalMethodTest(p))5136 assert.Equal(t, expected, actual)5137 })5138 T.Run("with multiple ownership", func(t *testing.T) {5139 t.Parallel()5140 p := buildExampleTodoListProject()5141 p.DataTypes = BuildOwnershipChain("Thing", "AnotherThing", "YetAnotherThing")5142 for i := range p.DataTypes {5143 p.DataTypes[i].BelongsToUser = true5144 p.DataTypes[i].RestrictedToUser = true5145 }5146 expected := `5147package main5148import ()5149func main() {5150 exampleFunction(ctx, exampleThing.ID, exampleAnotherThing.ID, exampleUser.ID, filter)5151}5152`5153 actual := renderCallArgsToString(t, p.LastDataType().BuildRequisiteFakeVarCallArgsForDBQueriersListRetrievalMethodTest(p))5154 assert.Equal(t, expected, actual)5155 })5156}5157func TestDataType_BuildRequisiteFakeVarCallArgsForDBQueriersArchiveMethodTest(T *testing.T) {5158 T.Parallel()5159 T.Run("obligatory", func(t *testing.T) {5160 t.Parallel()5161 dt := DataType{5162 Name: wordsmith.FromSingularPascalCase("Thing"),5163 }5164 expected := `5165package main5166import ()5167func main() {5168 exampleFunction(ctx, exampleThing.ID)5169}5170`5171 actual := renderCallArgsToString(t, dt.BuildRequisiteFakeVarCallArgsForDBQueriersArchiveMethodTest())5172 assert.Equal(t, expected, actual)5173 })5174 T.Run("with multiple ownership", func(t *testing.T) {5175 t.Parallel()5176 dt := DataType{5177 BelongsToStruct: wordsmith.FromSingularPascalCase("Thing"),5178 Name: wordsmith.FromSingularPascalCase("AnotherThing"),5179 BelongsToUser: true,5180 }5181 expected := `5182package main5183import ()5184func main() {5185 exampleFunction(ctx, exampleThing.ID, exampleAnotherThing.ID, exampleUser.ID)5186}5187`5188 actual := renderCallArgsToString(t, dt.BuildRequisiteFakeVarCallArgsForDBQueriersArchiveMethodTest())5189 assert.Equal(t, expected, actual)5190 })5191}5192func TestDataType_BuildCallArgsForDBClientCreationMethodTest(T *testing.T) {5193 T.Parallel()5194 T.Run("obligatory", func(t *testing.T) {5195 t.Parallel()5196 dt := DataType{5197 Name: wordsmith.FromSingularPascalCase("Thing"),5198 }5199 expected := `5200package main5201import ()5202func main() {5203 exampleFunction(ctx, exampleInput)5204}5205`5206 actual := renderCallArgsToString(t, dt.BuildCallArgsForDBClientCreationMethodTest())5207 assert.Equal(t, expected, actual)5208 })5209}5210func TestDataType_BuildCallArgsForDBClientListRetrievalMethodTest(T *testing.T) {5211 T.Parallel()5212 T.Run("obligatory", func(t *testing.T) {5213 t.Parallel()5214 p := buildExampleTodoListProject()5215 p.DataTypes = BuildOwnershipChain("Thing", "AnotherThing", "YetAnotherThing")5216 expected := `5217package main5218import ()5219func main() {5220 exampleFunction(exampleThing.ID, exampleAnotherThing.ID)5221}5222`5223 actual := renderCallArgsToString(t, p.LastDataType().BuildCallArgsForDBClientListRetrievalMethodTest(p))5224 assert.Equal(t, expected, actual)5225 })5226 T.Run("with user restriction", func(t *testing.T) {5227 t.Parallel()5228 p := buildExampleTodoListProject()5229 p.DataTypes = BuildOwnershipChain("Thing", "AnotherThing", "YetAnotherThing")5230 p.DataTypes[0].RestrictedToUser = true5231 p.DataTypes[0].BelongsToUser = true5232 expected := `5233package main5234import ()5235func main() {5236 exampleFunction(exampleThing.ID, exampleAnotherThing.ID, exampleUser.ID)5237}5238`5239 actual := renderCallArgsToString(t, p.LastDataType().BuildCallArgsForDBClientListRetrievalMethodTest(p))5240 assert.Equal(t, expected, actual)5241 })5242}5243func TestDataType_BuildRequisiteVarsForDBClientUpdateMethodTest(T *testing.T) {5244 T.Parallel()5245 T.Run("obligatory", func(t *testing.T) {5246 t.Parallel()5247 p := buildExampleTodoListProject()5248 p.DataTypes = BuildOwnershipChain("Thing", "AnotherThing", "YetAnotherThing")5249 expected := `5250package main5251import (5252 "context"5253 fake "gitlab.com/verygoodsoftwarenotvirus/example/models/v1/fake"5254)5255func main() {5256 ctx := context.Background()5257 var expected error5258 exampleYetAnotherThing := fake.BuildFakeYetAnotherThing()5259}5260`5261 actual := renderVariableDeclarationsToString(t, p.LastDataType().BuildRequisiteVarsForDBClientUpdateMethodTest(p))5262 assert.Equal(t, expected, actual)5263 })5264 T.Run("with multiple ownership", func(t *testing.T) {5265 t.Parallel()5266 p := buildExampleTodoListProject()5267 p.DataTypes = BuildOwnershipChain("Thing", "AnotherThing", "YetAnotherThing")5268 for i := range p.DataTypes {5269 p.DataTypes[i].BelongsToUser = true5270 p.DataTypes[i].RestrictedToUser = true5271 }5272 expected := `5273package main5274import (5275 "context"5276 fake "gitlab.com/verygoodsoftwarenotvirus/example/models/v1/fake"5277)5278func main() {5279 ctx := context.Background()5280 var expected error...

Full Screen

Full Screen

plugin_test.go

Source:plugin_test.go Github

copy

Full Screen

...66 } else {67 prettyPrintf("cd %s\n", altRoot)68 }69 os.Setenv("PWD", altRoot)70 goCmd(nil, "build", "-buildmode=plugin", "-o", filepath.Join(modRoot, "plugin-mismatch.so"), "./plugin-mismatch")71 os.Setenv("GOPATH", GOPATH)72 if err := os.Chdir(modRoot); err != nil {73 log.Panic(err)74 } else {75 prettyPrintf("cd %s\n", modRoot)76 }77 os.Setenv("PWD", modRoot)78 os.Setenv("LD_LIBRARY_PATH", modRoot)79 goCmd(nil, "build", "-buildmode=plugin", "./plugin1")80 goCmd(nil, "build", "-buildmode=plugin", "./plugin2")81 so, err := os.ReadFile("plugin2.so")82 if err != nil {83 log.Panic(err)84 }85 if err := os.WriteFile("plugin2-dup.so", so, 0444); err != nil {86 log.Panic(err)87 }88 prettyPrintf("cp plugin2.so plugin2-dup.so\n")89 goCmd(nil, "build", "-buildmode=plugin", "-o=sub/plugin1.so", "./sub/plugin1")90 goCmd(nil, "build", "-buildmode=plugin", "-o=unnamed1.so", "./unnamed1/main.go")91 goCmd(nil, "build", "-buildmode=plugin", "-o=unnamed2.so", "./unnamed2/main.go")92 goCmd(nil, "build", "-o", "host.exe", "./host")93 return m.Run()94}95func goCmd(t *testing.T, op string, args ...string) {96 if t != nil {97 t.Helper()98 }99 run(t, "go", append([]string{op, "-gcflags", gcflags}, args...)...)100}101// escape converts a string to something suitable for a shell command line.102func escape(s string) string {103 s = strings.Replace(s, "\\", "\\\\", -1)104 s = strings.Replace(s, "'", "\\'", -1)105 // Conservative guess at characters that will force quoting106 if s == "" || strings.ContainsAny(s, "\\ ;#*&$~?!|[]()<>{}`") {107 s = "'" + s + "'"108 }109 return s110}111// asCommandLine renders cmd as something that could be copy-and-pasted into a command line112func asCommandLine(cwd string, cmd *exec.Cmd) string {113 s := "("114 if cmd.Dir != "" && cmd.Dir != cwd {115 s += "cd" + escape(cmd.Dir) + ";"116 }117 for _, e := range cmd.Env {118 if !strings.HasPrefix(e, "PATH=") &&119 !strings.HasPrefix(e, "HOME=") &&120 !strings.HasPrefix(e, "USER=") &&121 !strings.HasPrefix(e, "SHELL=") {122 s += " "123 s += escape(e)124 }125 }126 // These EVs are relevant to this test.127 for _, e := range os.Environ() {128 if strings.HasPrefix(e, "PWD=") ||129 strings.HasPrefix(e, "GOPATH=") ||130 strings.HasPrefix(e, "LD_LIBRARY_PATH=") {131 s += " "132 s += escape(e)133 }134 }135 for _, a := range cmd.Args {136 s += " "137 s += escape(a)138 }139 s += " )"140 return s141}142func run(t *testing.T, bin string, args ...string) string {143 cmd := exec.Command(bin, args...)144 cmdLine := asCommandLine(".", cmd)145 prettyPrintf("%s\n", cmdLine)146 cmd.Stderr = new(strings.Builder)147 out, err := cmd.Output()148 if err != nil {149 if t == nil {150 log.Panicf("%s: %v\n%s", strings.Join(cmd.Args, " "), err, cmd.Stderr)151 } else {152 t.Helper()153 t.Fatalf("%s: %v\n%s", strings.Join(cmd.Args, " "), err, cmd.Stderr)154 }155 }156 return string(bytes.TrimSpace(out))157}158func TestDWARFSections(t *testing.T) {159 // test that DWARF sections are emitted for plugins and programs importing "plugin"160 goCmd(t, "run", "./checkdwarf/main.go", "plugin2.so", "plugin2.UnexportedNameReuse")161 goCmd(t, "run", "./checkdwarf/main.go", "./host.exe", "main.main")162}163func TestRunHost(t *testing.T) {164 run(t, "./host.exe")165}166func TestUniqueTypesAndItabs(t *testing.T) {167 goCmd(t, "build", "-buildmode=plugin", "./iface_a")168 goCmd(t, "build", "-buildmode=plugin", "./iface_b")169 goCmd(t, "build", "-o", "iface.exe", "./iface")170 run(t, "./iface.exe")171}172func TestIssue18676(t *testing.T) {173 // make sure we don't add the same itab twice.174 // The buggy code hangs forever, so use a timeout to check for that.175 goCmd(t, "build", "-buildmode=plugin", "-o", "plugin.so", "./issue18676/plugin.go")176 goCmd(t, "build", "-o", "issue18676.exe", "./issue18676/main.go")177 ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)178 defer cancel()179 cmd := exec.CommandContext(ctx, "./issue18676.exe")180 out, err := cmd.CombinedOutput()181 if err != nil {182 t.Fatalf("%s: %v\n%s", strings.Join(cmd.Args, " "), err, out)183 }184}185func TestIssue19534(t *testing.T) {186 // Test that we can load a plugin built in a path with non-alpha characters.187 goCmd(t, "build", "-buildmode=plugin", "-ldflags='-pluginpath=issue.19534'", "-o", "plugin.so", "./issue19534/plugin.go")188 goCmd(t, "build", "-o", "issue19534.exe", "./issue19534/main.go")189 run(t, "./issue19534.exe")190}191func TestIssue18584(t *testing.T) {192 goCmd(t, "build", "-buildmode=plugin", "-o", "plugin.so", "./issue18584/plugin.go")193 goCmd(t, "build", "-o", "issue18584.exe", "./issue18584/main.go")194 run(t, "./issue18584.exe")195}196func TestIssue19418(t *testing.T) {197 goCmd(t, "build", "-buildmode=plugin", "-ldflags=-X main.Val=linkstr", "-o", "plugin.so", "./issue19418/plugin.go")198 goCmd(t, "build", "-o", "issue19418.exe", "./issue19418/main.go")199 run(t, "./issue19418.exe")200}201func TestIssue19529(t *testing.T) {202 goCmd(t, "build", "-buildmode=plugin", "-o", "plugin.so", "./issue19529/plugin.go")203}204func TestIssue22175(t *testing.T) {205 goCmd(t, "build", "-buildmode=plugin", "-o", "issue22175_plugin1.so", "./issue22175/plugin1.go")206 goCmd(t, "build", "-buildmode=plugin", "-o", "issue22175_plugin2.so", "./issue22175/plugin2.go")207 goCmd(t, "build", "-o", "issue22175.exe", "./issue22175/main.go")208 run(t, "./issue22175.exe")209}210func TestIssue22295(t *testing.T) {211 goCmd(t, "build", "-buildmode=plugin", "-o", "issue.22295.so", "./issue22295.pkg")212 goCmd(t, "build", "-o", "issue22295.exe", "./issue22295.pkg/main.go")213 run(t, "./issue22295.exe")214}215func TestIssue24351(t *testing.T) {216 goCmd(t, "build", "-buildmode=plugin", "-o", "issue24351.so", "./issue24351/plugin.go")217 goCmd(t, "build", "-o", "issue24351.exe", "./issue24351/main.go")218 run(t, "./issue24351.exe")219}220func TestIssue25756(t *testing.T) {221 goCmd(t, "build", "-buildmode=plugin", "-o", "life.so", "./issue25756/plugin")222 goCmd(t, "build", "-o", "issue25756.exe", "./issue25756/main.go")223 // Fails intermittently, but 20 runs should cause the failure224 for n := 20; n > 0; n-- {225 t.Run(fmt.Sprint(n), func(t *testing.T) {226 t.Parallel()227 run(t, "./issue25756.exe")228 })229 }230}231// Test with main using -buildmode=pie with plugin for issue #43228232func TestIssue25756pie(t *testing.T) {233 goCmd(t, "build", "-buildmode=plugin", "-o", "life.so", "./issue25756/plugin")234 goCmd(t, "build", "-buildmode=pie", "-o", "issue25756pie.exe", "./issue25756/main.go")235 run(t, "./issue25756pie.exe")236}237func TestMethod(t *testing.T) {238 // Exported symbol's method must be live.239 goCmd(t, "build", "-buildmode=plugin", "-o", "plugin.so", "./method/plugin.go")240 goCmd(t, "build", "-o", "method.exe", "./method/main.go")241 run(t, "./method.exe")242}243func TestMethod2(t *testing.T) {244 goCmd(t, "build", "-buildmode=plugin", "-o", "method2.so", "./method2/plugin.go")245 goCmd(t, "build", "-o", "method2.exe", "./method2/main.go")246 run(t, "./method2.exe")247}248func TestIssue44956(t *testing.T) {249 goCmd(t, "build", "-buildmode=plugin", "-o", "issue44956p1.so", "./issue44956/plugin1.go")250 goCmd(t, "build", "-buildmode=plugin", "-o", "issue44956p2.so", "./issue44956/plugin2.go")251 goCmd(t, "build", "-o", "issue44956.exe", "./issue44956/main.go")252 run(t, "./issue44956.exe")253}254func TestForkExec(t *testing.T) {255 // Issue 38824: importing the plugin package causes it hang in forkExec on darwin.256 t.Parallel()257 goCmd(t, "build", "-o", "forkexec.exe", "./forkexec/main.go")258 var cmd *exec.Cmd259 done := make(chan int, 1)260 go func() {261 for i := 0; i < 100; i++ {262 cmd = exec.Command("./forkexec.exe", "1")263 err := cmd.Run()264 if err != nil {265 t.Errorf("running command failed: %v", err)266 break267 }268 }269 done <- 1270 }()271 select {...

Full Screen

Full Screen

build

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 fmt.Println("Hello World")4}5import (6func main() {7 fmt.Println("Hello World")8}9import (10func main() {11 fmt.Println("Hello World")12}13import (14func main() {15 fmt.Println("Hello World")16}

Full Screen

Full Screen

build

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 fmt.Println("Hello World")4}5import (6func main()

Full Screen

Full Screen

build

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 fmt.Println("Hello World")4}5import (6func main() {7 fmt.Println("Hello World")8}9import (10func main() {11 fmt.Println("Hello World")12}13import (14func main() {15 fmt.Println("Hello World")16}17import (18func main() {19 fmt.Println("Hello World")20}21import (22func main() {23 fmt.Println("Hello World")24}25import (26func main() {27 fmt.Println("Hello World")28}29import (30func main() {31 fmt.Println("Hello World")32}33import (34func main() {35 fmt.Println("Hello World")36}37import (38func main() {39 fmt.Println("Hello World")40}41import (42func main() {43 fmt.Println("Hello World")44}45import (46func main() {47 fmt.Println("Hello World")48}49import (50func main() {51 fmt.Println("Hello World")52}53import (54func main() {55 fmt.Println("Hello World")56}57import (58func main() {59 fmt.Println("Hello World")60}61import (62func main() {63 fmt.Println("Hello World")64}65import (66func main() {67 fmt.Println("Hello World")68}69import (70func main() {71 fmt.Println("Hello World")72}73import (74func main()

Full Screen

Full Screen

build

Using AI Code Generation

copy

Full Screen

1import "fmt"2type Person struct{3}4func (p *Person) Build(name string, age int) {5}6func main() {7 p.Build("John", 23)8 fmt.Println(p)9}10{John 23}11import "fmt"12type Person struct{13}14func main() {15 fmt.Println(p)16}17{John 23}18import "fmt"19type Person struct{20}21func main() {22 p := Person{"John", 23}23 fmt.Println(p)24}25{John 23}26import "fmt"27type Person struct{28}29func main() {30 p := Person{name: "John", age: 23}31 fmt.Println(p)32}33{John 23}34import "fmt"35type Person struct{36}37func main() {38 p := Person{name: "John"}39 fmt.Println(p)40}41{John 0}42import "fmt"43type Person struct{44}45func main() {46 p := Person{}47 fmt.Println(p)48}49{ 0}50import "fmt"51type Person struct{52}53func main() {54 p := new(Person)55 fmt.Println(p)56}57&{ 0}58import "fmt"59type Person struct{60}61func main() {62 p := &Person{}63 fmt.Println(p)64}

Full Screen

Full Screen

build

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 cmd := exec.Command("go", "build")4 err := cmd.Run()5 if err != nil {6 fmt.Println(err)7 }8 fmt.Println("Build successful")9}

Full Screen

Full Screen

build

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 fmt.Println("Hello, world!")4 fmt.Println(math.Pi)5}6import (7func main() {8 fmt.Println("A number from 1-100", rand.Intn(100))9}10import (11func main() {12 fmt.Println(math.Pi)13}14import (15func main() {16 fmt.Println("Hello, world!")17}18import (19func main() {20 fmt.Println("Hello, world!")21}22import (23func main() {24 fmt.Println("Hello, world!")25 fmt.Println(math.Pi)26}27import (28func main() {29 fmt.Println(math.Pi)30}31import (32func main() {33 fmt.Println("A number from 1-100", rand.Intn(100))34}35import (36func main() {37 fmt.Println(math.Pi)38}39import (40func main() {

Full Screen

Full Screen

build

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 fmt.Println("Hello, World")4 time.Sleep(1 * time.Second)5}6import (7func main() {8 fmt.Println("Hello, World")9 time.Sleep(5 * time.Second)10 fmt.Println("Hello, World after 5 seconds")11}

Full Screen

Full Screen

build

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 r := geometry.Rectangle{Width: 3, Height: 4}4 fmt.Println("Area of rectangle is:", r.Area())5}6import (7import (8func main() {9 r := geometry.Rectangle{Width: 3, Height: 4}10 fmt.Println("Area of rectangle is:", r.Area())11}12import (13import (14func main() {15 r := geometry.Rectangle{Width: 3, Height: 4}

Full Screen

Full Screen

build

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 builder = &BuilderImpl{}4 director := Director{5 }6 director.buildProduct()7 product := builder.getProduct()8 fmt.Println(product)9}10import (11func main() {12 builder = &BuilderImpl{}13 director := Director{14 }15 director.buildProduct()16 product := builder.getProduct()17 fmt.Println(product)18}19import (20func main() {21 builder = &BuilderImpl{}22 director := Director{23 }24 director.buildProduct()25 product := builder.getProduct()26 fmt.Println(product)27}28import (29func main() {30 builder = &BuilderImpl{}31 director := Director{32 }33 director.buildProduct()34 product := builder.getProduct()35 fmt.Println(product)36}37import (38func main() {39 builder = &BuilderImpl{}40 director := Director{41 }42 director.buildProduct()43 product := builder.getProduct()44 fmt.Println(product)45}46import (47func main() {48 builder = &BuilderImpl{}49 director := Director{50 }51 director.buildProduct()52 product := builder.getProduct()53 fmt.Println(product)54}55import (56func main() {57 builder = &BuilderImpl{}58 director := Director{59 }60 director.buildProduct()61 product := builder.getProduct()62 fmt.Println(product)63}

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Syzkaller automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used method in

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful