@@ -171,13 +171,15 @@ func TestStorageInitOpts_Ask(t *testing.T) {
171171 inPartition string
172172 inSort string
173173 inLSISorts []string
174- inNoLsi bool
174+ inNoLSI bool
175175 inNoSort bool
176176
177177 mockPrompt func (m * mocks.Mockprompter )
178178 mockCfg func (m * mocks.MockconfigSelector )
179179
180180 wantedErr error
181+
182+ wantedVars * initStorageVars
181183 }{
182184 "Asks for storage type" : {
183185 inAppName : wantedAppName ,
@@ -265,7 +267,7 @@ func TestStorageInitOpts_Ask(t *testing.T) {
265267 inStorageType : dynamoDBStorageType ,
266268 inStorageName : wantedTableName ,
267269 inSort : wantedSortKey ,
268- inNoLsi : true ,
270+ inNoLSI : true ,
269271
270272 mockPrompt : func (m * mocks.Mockprompter ) {
271273 keyPrompt := fmt .Sprintf (fmtStorageInitDDBKeyPrompt ,
@@ -334,7 +336,7 @@ func TestStorageInitOpts_Ask(t *testing.T) {
334336 inStorageType : dynamoDBStorageType ,
335337 inStorageName : wantedTableName ,
336338 inPartition : wantedPartitionKey ,
337- inNoLsi : true ,
339+ inNoLSI : true ,
338340
339341 mockPrompt : func (m * mocks.Mockprompter ) {
340342 m .EXPECT ().Confirm (
@@ -438,7 +440,7 @@ func TestStorageInitOpts_Ask(t *testing.T) {
438440 inStorageName : wantedTableName ,
439441 inPartition : wantedPartitionKey ,
440442 inNoSort : true ,
441- inNoLsi : true ,
443+ inNoLSI : true ,
442444
443445 mockPrompt : func (m * mocks.Mockprompter ) {},
444446 mockCfg : func (m * mocks.MockconfigSelector ) {},
@@ -452,7 +454,7 @@ func TestStorageInitOpts_Ask(t *testing.T) {
452454 inStorageName : wantedTableName ,
453455 inPartition : wantedPartitionKey ,
454456 inSort : wantedSortKey ,
455- inNoLsi : true ,
457+ inNoLSI : true ,
456458
457459 mockPrompt : func (m * mocks.Mockprompter ) {},
458460 mockCfg : func (m * mocks.MockconfigSelector ) {},
@@ -507,6 +509,50 @@ func TestStorageInitOpts_Ask(t *testing.T) {
507509 ).Return (false , nil )
508510 },
509511 mockCfg : func (m * mocks.MockconfigSelector ) {},
512+
513+ wantedVars : & initStorageVars {
514+ GlobalOpts : & GlobalOpts {
515+ appName : wantedAppName ,
516+ },
517+ storageName : wantedTableName ,
518+ storageSvc : wantedSvcName ,
519+ storageType : dynamoDBStorageType ,
520+
521+ partitionKey : wantedPartitionKey ,
522+ sortKey : wantedSortKey ,
523+ noLSI : false ,
524+ lsiSorts : []string {"Email:S" },
525+ },
526+ },
527+ "noLSI is set correctly if no lsis specified" : {
528+ inAppName : wantedAppName ,
529+ inSvcName : wantedSvcName ,
530+ inStorageType : dynamoDBStorageType ,
531+ inStorageName : wantedTableName ,
532+ inPartition : wantedPartitionKey ,
533+ inSort : wantedSortKey ,
534+
535+ mockPrompt : func (m * mocks.Mockprompter ) {
536+ m .EXPECT ().Confirm (
537+ gomock .Eq (storageInitDDBLSIPrompt ),
538+ gomock .Eq (storageInitDDBLSIHelp ),
539+ gomock .Any (),
540+ ).Return (false , nil )
541+ },
542+ mockCfg : func (m * mocks.MockconfigSelector ) {},
543+
544+ wantedVars : & initStorageVars {
545+ GlobalOpts : & GlobalOpts {
546+ appName : wantedAppName ,
547+ },
548+ storageName : wantedTableName ,
549+ storageSvc : wantedSvcName ,
550+ storageType : dynamoDBStorageType ,
551+
552+ partitionKey : wantedPartitionKey ,
553+ sortKey : wantedSortKey ,
554+ noLSI : true ,
555+ },
510556 },
511557 "error if lsi name misspecified" : {
512558 inAppName : wantedAppName ,
@@ -616,7 +662,7 @@ func TestStorageInitOpts_Ask(t *testing.T) {
616662 partitionKey : tc .inPartition ,
617663 sortKey : tc .inSort ,
618664 lsiSorts : tc .inLSISorts ,
619- noLsi : tc .inNoLsi ,
665+ noLSI : tc .inNoLSI ,
620666 noSort : tc .inNoSort ,
621667 },
622668 sel : mockConfig ,
@@ -632,6 +678,10 @@ func TestStorageInitOpts_Ask(t *testing.T) {
632678 } else {
633679 require .Nil (t , err )
634680 }
681+ if tc .wantedVars != nil {
682+ tc .wantedVars .prompt = opts .prompt
683+ require .Equal (t , * tc .wantedVars , opts .initStorageVars )
684+ }
635685 })
636686 }
637687}
@@ -654,7 +704,7 @@ func TestStorageInitOpts_Execute(t *testing.T) {
654704 inPartition string
655705 inSort string
656706 inLSISorts []string
657- inNoLsi bool
707+ inNoLSI bool
658708 inNoSort bool
659709
660710 mockWs func (m * mocks.MockwsAddonManager )
@@ -678,7 +728,7 @@ func TestStorageInitOpts_Execute(t *testing.T) {
678728 inStorageType : dynamoDBStorageType ,
679729 inSvcName : wantedSvcName ,
680730 inStorageName : "my-table" ,
681- inNoLsi : true ,
731+ inNoLSI : true ,
682732 inNoSort : true ,
683733 inPartition : wantedPartitionKey ,
684734
@@ -746,7 +796,7 @@ func TestStorageInitOpts_Execute(t *testing.T) {
746796 partitionKey : tc .inPartition ,
747797 sortKey : tc .inSort ,
748798 lsiSorts : tc .inLSISorts ,
749- noLsi : tc .inNoLsi ,
799+ noLSI : tc .inNoLSI ,
750800 noSort : tc .inNoSort ,
751801 },
752802 ws : mockAddon ,
0 commit comments