File tree 2 files changed +43
-2
lines changed 2 files changed +43
-2
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ import { ObjectExplorerUtils } from "../objectExplorerUtils";
10
10
import * as Constants from "../../constants/constants" ;
11
11
import { ITreeNodeInfo , ObjectMetadata } from "vscode-mssql" ;
12
12
import { IConnectionProfile } from "../../models/interfaces" ;
13
+ import { generateGuid } from "../../models/utils" ;
13
14
14
15
export class TreeNodeInfo extends vscode . TreeItem implements ITreeNodeInfo {
15
16
private _nodePath : string ;
@@ -68,9 +69,9 @@ export class TreeNodeInfo extends vscode.TreeItem implements ITreeNodeInfo {
68
69
this . id = this . generateId ( ) ;
69
70
}
70
71
71
- // Gernating a unique ID for the node
72
+ // Generating a unique ID for the node
72
73
protected generateId ( ) : string {
73
- return `${ this . _connectionProfile ?. id } -${ this . _nodePath } -${ Date . now ( ) } ` ;
74
+ return `${ this . _connectionProfile ?. id } -${ this . _nodePath } -${ generateGuid ( ) } ` ;
74
75
}
75
76
76
77
public static fromNodeInfo (
Original file line number Diff line number Diff line change
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License. See License.txt in the project root for license information.
4
+ *--------------------------------------------------------------------------------------------*/
5
+
6
+ import { expect } from "chai" ;
7
+ import { TreeNodeInfo } from "../../src/objectExplorer/nodes/treeNodeInfo" ;
8
+
9
+ suite ( "TreeNodeInfo" , ( ) => {
10
+ test ( "When creating multiple TreeNodeInfo in quick succession, the nodePath should be unique" , ( ) => {
11
+ const node1 = new TreeNodeInfo (
12
+ "node_label" ,
13
+ undefined ,
14
+ undefined ,
15
+ "node_path" ,
16
+ undefined ,
17
+ undefined ,
18
+ "session_id" ,
19
+ undefined ,
20
+ undefined ,
21
+ undefined ,
22
+ undefined ,
23
+ ) ;
24
+
25
+ const node2 = new TreeNodeInfo (
26
+ "node_label" ,
27
+ undefined ,
28
+ undefined ,
29
+ "node_path" ,
30
+ undefined ,
31
+ undefined ,
32
+ "session_id" ,
33
+ undefined ,
34
+ undefined ,
35
+ undefined ,
36
+ undefined ,
37
+ ) ;
38
+ expect ( node1 . id ) . to . not . equal ( node2 . id , "Node IDs should be unique" ) ;
39
+ } ) ;
40
+ } ) ;
You can’t perform that action at this time.
0 commit comments