@@ -142,7 +142,9 @@ func TestAddRepeatedNewWithConstraint(t *testing.T) {
142142 m , err = p .Run ()
143143 require .NoError (t , err )
144144 assert .Equal (t , 0 , m .(HasStatus ).Status ())
145- assert .Contains (t , out .String (), "old constraint: any; new constraint: >=1.0.0" )
145+ if fo , ok := m .(HasFinalOutput ); ok {
146+ assert .Contains (t , fo .FinalOutput (), "old constraint: any; new constraint: >=1.0.0" )
147+ }
146148
147149 data , err := os .ReadFile (filepath .Join (dir , "dbc.toml" ))
148150 require .NoError (t , err )
@@ -409,3 +411,60 @@ func (suite *SubcommandTestSuite) TestAddCompleteRegistryFailure() {
409411 suite .Contains (out , "error getting driver list" )
410412 suite .Contains (out , "network unreachable" )
411413}
414+
415+ func (suite * SubcommandTestSuite ) TestAddOutput () {
416+ m := InitCmd {Path : filepath .Join (suite .tempdir , "dbc.toml" )}.GetModel ()
417+ suite .runCmd (m )
418+
419+ m = AddCmd {
420+ Path : filepath .Join (suite .tempdir , "dbc.toml" ),
421+ Driver : []string {"test-driver-1" },
422+ }.GetModelCustom (
423+ baseModel {getDriverRegistry : getTestDriverRegistry , downloadPkg : downloadTestPkg })
424+
425+ out := suite .runCmd (m )
426+ suite .Contains (out , "added test-driver-1 to driver list" )
427+ suite .Contains (out , "use `dbc sync` to install the drivers in the list" )
428+ }
429+
430+ func (suite * SubcommandTestSuite ) TestAddMultipleOutput () {
431+ m := InitCmd {Path : filepath .Join (suite .tempdir , "dbc.toml" )}.GetModel ()
432+ suite .runCmd (m )
433+
434+ m = AddCmd {
435+ Path : filepath .Join (suite .tempdir , "dbc.toml" ),
436+ Driver : []string {"test-driver-1" , "test-driver-2" },
437+ }.GetModelCustom (
438+ baseModel {getDriverRegistry : getTestDriverRegistry , downloadPkg : downloadTestPkg })
439+
440+ out := suite .runCmd (m )
441+ suite .Contains (out , "added test-driver-1 to driver list" )
442+ suite .Contains (out , "added test-driver-2 to driver list" )
443+ suite .Contains (out , "use `dbc sync` to install the drivers in the list" )
444+ }
445+
446+ func (suite * SubcommandTestSuite ) TestAddReplacingDriverOutput () {
447+ m := InitCmd {Path : filepath .Join (suite .tempdir , "dbc.toml" )}.GetModel ()
448+ suite .runCmd (m )
449+
450+ // Add driver without constraint
451+ m = AddCmd {
452+ Path : filepath .Join (suite .tempdir , "dbc.toml" ),
453+ Driver : []string {"test-driver-1" },
454+ }.GetModelCustom (
455+ baseModel {getDriverRegistry : getTestDriverRegistry , downloadPkg : downloadTestPkg })
456+ suite .runCmd (m )
457+
458+ // Add same driver with constraint and verify replacement message
459+ m = AddCmd {
460+ Path : filepath .Join (suite .tempdir , "dbc.toml" ),
461+ Driver : []string {"test-driver-1>=1.0.0" },
462+ }.GetModelCustom (
463+ baseModel {getDriverRegistry : getTestDriverRegistry , downloadPkg : downloadTestPkg })
464+
465+ out := suite .runCmd (m )
466+ suite .Contains (out , "replacing existing driver test-driver-1" )
467+ suite .Contains (out , "old constraint: any; new constraint: >=1.0.0" )
468+ suite .Contains (out , "added test-driver-1 to driver list" )
469+ suite .Contains (out , "with constraint >=1.0.0" )
470+ }
0 commit comments