File tree Expand file tree Collapse file tree
extensions/ql-vscode/test/unit-tests/databases/config Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import { join } from "path";
33import { App } from "../../../../src/common/app" ;
44import {
55 DbConfig ,
6+ SelectedDbItem ,
67 SelectedDbItemKind ,
78} from "../../../../src/databases/config/db-config" ;
89import { DbConfigStore } from "../../../../src/databases/config/db-config-store" ;
@@ -636,4 +637,40 @@ describe("db config store", () => {
636637 configStore . dispose ( ) ;
637638 } ) ;
638639 } ) ;
640+
641+ describe ( "set selected item" , ( ) => {
642+ let app : App ;
643+ let configPath : string ;
644+
645+ beforeEach ( async ( ) => {
646+ app = createMockApp ( {
647+ extensionPath,
648+ workspaceStoragePath : tempWorkspaceStoragePath ,
649+ } ) ;
650+
651+ configPath = join ( tempWorkspaceStoragePath , "workspace-databases.json" ) ;
652+ } ) ;
653+
654+ it ( "should set the selected item" , async ( ) => {
655+ // Initial set up
656+ const configStore = new DbConfigStore ( app ) ;
657+ await configStore . initialize ( ) ;
658+
659+ // Set selected
660+ const selectedItem : SelectedDbItem = {
661+ kind : SelectedDbItemKind . RemoteOwner ,
662+ ownerName : "owner2" ,
663+ } ;
664+
665+ await configStore . setSelectedDbItem ( selectedItem ) ;
666+
667+ // Read the config file
668+ const updatedDbConfig = ( await readJSON ( configPath ) ) as DbConfig ;
669+
670+ // Check that the config file has been updated
671+ expect ( updatedDbConfig . selected ) . toEqual ( selectedItem ) ;
672+
673+ configStore . dispose ( ) ;
674+ } ) ;
675+ } ) ;
639676} ) ;
You can’t perform that action at this time.
0 commit comments