(t *testing.T)
| 506 | } |
| 507 | |
| 508 | func TestBuildCollectionIndexData(t *testing.T) { |
| 509 | tests := []struct { |
| 510 | name string |
| 511 | config *DatabaseConfig |
| 512 | want CollectionInitData |
| 513 | }{ |
| 514 | { |
| 515 | name: "implicit default collection", |
| 516 | config: &DatabaseConfig{ |
| 517 | DbConfig: DbConfig{ |
| 518 | Scopes: nil, |
| 519 | }, |
| 520 | }, |
| 521 | want: CollectionInitData{ |
| 522 | base.DefaultScopeAndCollectionName(): db.IndexesAll, |
| 523 | }, |
| 524 | }, |
| 525 | { |
| 526 | name: "explicit default collection", |
| 527 | config: &DatabaseConfig{ |
| 528 | DbConfig: DbConfig{ |
| 529 | Scopes: makeScopesConfig(base.DefaultScope, []string{base.DefaultCollection}), |
| 530 | }, |
| 531 | }, |
| 532 | want: CollectionInitData{ |
| 533 | base.DefaultScopeAndCollectionName(): db.IndexesAll, |
| 534 | }, |
| 535 | }, |
| 536 | { |
| 537 | name: "one named collection", |
| 538 | config: &DatabaseConfig{ |
| 539 | DbConfig: DbConfig{ |
| 540 | Scopes: makeScopesConfig("scope1", []string{"collection1"}), |
| 541 | }, |
| 542 | }, |
| 543 | want: CollectionInitData{ |
| 544 | base.DefaultScopeAndCollectionName(): db.IndexesMetadataOnly, |
| 545 | base.NewScopeAndCollectionName("scope1", "collection1"): db.IndexesWithoutMetadata, |
| 546 | }, |
| 547 | }, |
| 548 | { |
| 549 | name: "one named and explicit default collection", |
| 550 | config: &DatabaseConfig{ |
| 551 | DbConfig: DbConfig{ |
| 552 | Scopes: makeScopesConfig(base.DefaultScope, []string{base.DefaultCollection, "collection1"}), |
| 553 | }, |
| 554 | }, |
| 555 | want: CollectionInitData{ |
| 556 | base.DefaultScopeAndCollectionName(): db.IndexesAll, |
| 557 | base.NewScopeAndCollectionName(base.DefaultScope, "collection1"): db.IndexesWithoutMetadata, |
| 558 | }, |
| 559 | }, |
| 560 | } |
| 561 | for _, test := range tests { |
| 562 | t.Run(test.name, func(t *testing.T) { |
| 563 | actual := buildCollectionIndexData(test.config) |
| 564 | assert.Equalf(t, test.want, actual, "buildCollectionIndexData(%v)", test.config) |
| 565 | }) |
nothing calls this directly
no test coverage detected