File tree Expand file tree Collapse file tree
vscode-tests/minimal-workspace/databases Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -76,6 +76,10 @@ export class DbManager {
7676 }
7777
7878 public async addNewRemoteList ( listName : string ) : Promise < void > {
79+ if ( listName === "" ) {
80+ throw Error ( "List name cannot be empty" ) ;
81+ }
82+
7983 if ( this . dbConfigStore . doesRemoteListExist ( listName ) ) {
8084 throw Error ( `A list with the name '${ listName } ' already exists` ) ;
8185 }
Original file line number Diff line number Diff line change @@ -549,6 +549,35 @@ describe("db panel", () => {
549549 ) ;
550550 } ) ;
551551
552+ describe ( "Name validation" , ( ) => {
553+ it ( "should not allow adding a new list with empty name" , async ( ) => {
554+ const dbConfig = createDbConfig ( ) ;
555+
556+ await saveDbConfig ( dbConfig ) ;
557+
558+ await expect ( dbManager . addNewRemoteList ( "" ) ) . rejects . toThrow (
559+ new Error ( "List name cannot be empty" ) ,
560+ ) ;
561+ } ) ;
562+
563+ it ( "should not allow adding a list with duplicate name" , async ( ) => {
564+ const dbConfig = createDbConfig ( {
565+ remoteLists : [
566+ {
567+ name : "my-list-1" ,
568+ repositories : [ "owner1/repo1" , "owner1/repo2" ] ,
569+ } ,
570+ ] ,
571+ } ) ;
572+
573+ await saveDbConfig ( dbConfig ) ;
574+
575+ await expect ( dbManager . addNewRemoteList ( "my-list-1" ) ) . rejects . toThrow (
576+ new Error ( "A list with the name 'my-list-1' already exists" ) ,
577+ ) ;
578+ } ) ;
579+ } ) ;
580+
552581 async function saveDbConfig ( dbConfig : DbConfig ) : Promise < void > {
553582 await writeJson ( dbConfigFilePath , dbConfig ) ;
554583
You can’t perform that action at this time.
0 commit comments