Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
test: fix unit tests (#14111)
rebelice99b2945fb269
diff --git a/backend/plugin/parser/mysql/completion_test.go b/backend/plugin/parser/mysql/completion_test.goindex 6475af687f..6b31aaf380 100644--- a/backend/plugin/parser/mysql/completion_test.go+++ b/backend/plugin/parser/mysql/completion_test.go@@ -4,6 +4,7 @@ import ("context""io""os"+ "sort""testing""github.com/stretchr/testify/require"@@ -56,6 +57,16 @@ func TestCompletion(t *testing.T) {filteredResult = append(filteredResult, r)}}+ sort.Slice(filteredResult, func(i, j int) bool {+ if filteredResult[i].Type != filteredResult[j].Type {+ return filteredResult[i].Type < filteredResult[j].Type+ }+ if filteredResult[i].Text != filteredResult[j].Text {+ return filteredResult[i].Text < filteredResult[j].Text+ }+ return filteredResult[i].Definition < filteredResult[j].Definition+ })+if record {tests[i].Want = filteredResult} else {diff --git a/backend/plugin/parser/mysql/test-data/test_completion.yaml b/backend/plugin/parser/mysql/test-data/test_completion.yamlindex 08111345a7..7a888976d2 100644--- a/backend/plugin/parser/mysql/test-data/test_completion.yaml+++ b/backend/plugin/parser/mysql/test-data/test_completion.yaml@@ -20,6 +20,10 @@comment: ""- input: INSERT INTO t1(|);want:+ - text: c1+ type: COLUMN+ definition: t1 | , NOT NULL+ comment: ""- text: dbtype: DATABASEdefinition: ""@@ -32,16 +36,20 @@type: TABLEdefinition: ""comment: ""- - text: c1- type: COLUMN- definition: t1 | , NOT NULL- comment: ""- text: v1type: VIEWdefinition: ""comment: ""- input: INSERT INTO t2(c1, |);want:+ - text: c1+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ - text: c2+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""- text: dbtype: DATABASEdefinition: ""@@ -54,14 +62,6 @@type: TABLEdefinition: ""comment: ""- - text: c1- type: COLUMN- definition: t2 | , NOT NULL- comment: ""- - text: c2- type: COLUMN- definition: t2 | , NOT NULL- comment: ""- text: v1type: VIEWdefinition: ""@@ -78,6 +78,14 @@comment: ""- input: WITH x(x1, x2) AS (SELECT * FROM t2) SELECT | FROM xwant:+ - text: x1+ type: COLUMN+ definition: ""+ comment: ""+ - text: x2+ type: COLUMN+ definition: ""+ comment: ""- text: dbtype: DATABASEdefinition: ""@@ -94,32 +102,12 @@type: TABLEdefinition: ""comment: ""- - text: x1- type: COLUMN- definition: ""- comment: ""- - text: x2- type: COLUMN- definition: ""- comment: ""- text: v1type: VIEWdefinition: ""comment: ""- input: SELECT c1 as eid, c2 as xid FROM t2 ORDER BY |want:- - text: db- type: DATABASE- definition: ""- comment: ""- - text: t1- type: TABLE- definition: ""- comment: ""- - text: t2- type: TABLE- definition: ""- comment: ""- text: c1type: COLUMNdefinition: t2 | , NOT NULL@@ -136,12 +124,6 @@type: COLUMNdefinition: ""comment: ""- - text: v1- type: VIEW- definition: ""- comment: ""-- input: SELECT c1 as eid FROM t1 ORDER BY |- want:- text: dbtype: DATABASEdefinition: ""@@ -154,6 +136,12 @@type: TABLEdefinition: ""comment: ""+ - text: v1+ type: VIEW+ definition: ""+ comment: ""+- input: SELECT c1 as eid FROM t1 ORDER BY |+ want:- text: c1type: COLUMNdefinition: t1 | , NOT NULL@@ -162,12 +150,28 @@type: COLUMNdefinition: ""comment: ""+ - text: db+ type: DATABASE+ definition: ""+ comment: ""+ - text: t1+ type: TABLE+ definition: ""+ comment: ""+ - text: t2+ type: TABLE+ definition: ""+ comment: ""- text: v1type: VIEWdefinition: ""comment: ""- input: SELECT FROM basdkfjasldf;SELECT | FROM t1want:+ - text: c1+ type: COLUMN+ definition: t1 | , NOT NULL+ comment: ""- text: dbtype: DATABASEdefinition: ""@@ -180,16 +184,16 @@type: TABLEdefinition: ""comment: ""- - text: c1- type: COLUMN- definition: t1 | , NOT NULL- comment: ""- text: v1type: VIEWdefinition: ""comment: ""- input: SELECT | FROM (SELECT c1 FROM t1) cc1(cc1c1)want:+ - text: cc1c1+ type: COLUMN+ definition: ""+ comment: ""- text: dbtype: DATABASEdefinition: ""@@ -206,16 +210,16 @@type: TABLEdefinition: ""comment: ""- - text: cc1c1- type: COLUMN- definition: ""- comment: ""- text: v1type: VIEWdefinition: ""comment: ""- input: SELECT | FROM (SELECT c1 FROM t1) cc1want:+ - text: c1+ type: COLUMN+ definition: ""+ comment: ""- text: dbtype: DATABASEdefinition: ""@@ -232,10 +236,6 @@type: TABLEdefinition: ""comment: ""- - text: c1- type: COLUMN- definition: ""- comment: ""- text: v1type: VIEWdefinition: ""@@ -276,6 +276,10 @@comment: ""- input: SELECT | FROM t1want:+ - text: c1+ type: COLUMN+ definition: t1 | , NOT NULL+ comment: ""- text: dbtype: DATABASEdefinition: ""@@ -288,16 +292,20 @@type: TABLEdefinition: ""comment: ""- - text: c1- type: COLUMN- definition: t1 | , NOT NULL- comment: ""- text: v1type: VIEWdefinition: ""comment: ""- input: SELECT | FROM t2 xwant:+ - text: c1+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""+ - text: c2+ type: COLUMN+ definition: t2 | , NOT NULL+ comment: ""- text: dbtype: DATABASEdefinition: ""@@ -314,14 +322,6 @@type: TABLEdefinition: ""comment: ""- - text: c1- type: COLUMN- definition: t2 | , NOT NULL- comment: ""- - text: c2- type: COLUMN- definition: t2 | , NOT NULL- comment: ""- text: v1type: VIEWdefinition: ""diff --git a/backend/plugin/parser/pg/completion_test.go b/backend/plugin/parser/pg/completion_test.goindex db34275f12..58eb31b3d4 100644--- a/backend/plugin/parser/pg/completion_test.go+++ b/backend/plugin/parser/pg/completion_test.go@@ -4,6 +4,7 @@ import ("context""io""os"+ "sort""testing""github.com/stretchr/testify/require"@@ -56,6 +57,16 @@ func TestCompletion(t *testing.T) {filteredResult = append(filteredResult, r)}}+ sort.Slice(filteredResult, func(i, j int) bool {+ if filteredResult[i].Type != filteredResult[j].Type {+ return filteredResult[i].Type < filteredResult[j].Type+ }+ if filteredResult[i].Text != filteredResult[j].Text {+ return filteredResult[i].Text < filteredResult[j].Text+ }+ return filteredResult[i].Definition < filteredResult[j].Definition+ })+if record {tests[i].Want = filteredResult} else {diff --git a/backend/plugin/parser/pg/test-data/test_completion.yaml b/backend/plugin/parser/pg/test-data/test_completion.yamlindex d3cf82c851..b1f01dd538 100644--- a/backend/plugin/parser/pg/test-data/test_completion.yaml+++ b/backend/plugin/parser/pg/test-data/test_completion.yaml@@ -50,6 +50,14 @@comment: ""- input: WITH x(x1, x2) AS (SELECT * FROM t2) SELECT | FROM xwant:+ - text: x1+ type: COLUMN+ definition: ""+ comment: ""+ - text: x2+ type: COLUMN+ definition: ""+ comment: ""- text: publictype: SCHEMAdefinition: ""@@ -70,16 +78,24 @@type: VIEWdefinition: ""comment: ""- - text: x1+- input: SELECT c1 as eid, c2 as xid FROM t2 ORDER BY |+ want:+ - text: c1+ type: COLUMN+ definition: public.t2 | int, NOT NULL+ comment: ""+ - text: c2+ type: COLUMN+ definition: public.t2 | int, NOT NULL+ comment: ""+ - text: eidtype: COLUMNdefinition: ""comment: ""- - text: x2+ - text: xidtype: COLUMNdefinition: ""comment: ""-- input: SELECT c1 as eid, c2 as xid FROM t2 ORDER BY |- want:- text: publictype: SCHEMAdefinition: ""@@ -96,24 +112,16 @@type: VIEWdefinition: ""comment: ""+- input: SELECT c1 as eid FROM t1 ORDER BY |+ want:- text: c1type: COLUMN- definition: public.t2 | int, NOT NULL- comment: ""- - text: c2- type: COLUMN- definition: public.t2 | int, NOT NULL+ definition: public.t1 | int, NOT NULLcomment: ""- text: eidtype: COLUMNdefinition: ""comment: ""- - text: xid- type: COLUMN- definition: ""- comment: ""-- input: SELECT c1 as eid FROM t1 ORDER BY |- want:- text: publictype: SCHEMAdefinition: ""@@ -130,16 +138,12 @@type: VIEWdefinition: ""comment: ""+- input: SELECT FROM basdkfjasldf;SELECT | FROM t1+ want:- text: c1type: COLUMNdefinition: public.t1 | int, NOT NULLcomment: ""- - text: eid- type: COLUMN- definition: ""- comment: ""-- input: SELECT FROM basdkfjasldf;SELECT | FROM t1- want:- text: publictype: SCHEMAdefinition: ""@@ -156,12 +160,12 @@type: VIEWdefinition: ""comment: ""+- input: SELECT | FROM (SELECT c1 FROM t1) cc1+ want:- text: c1type: COLUMN- definition: public.t1 | int, NOT NULL+ definition: ""comment: ""-- input: SELECT | FROM (SELECT c1 FROM t1) cc1- want:- text: publictype: SCHEMAdefinition: ""@@ -182,10 +186,6 @@type: VIEWdefinition: ""comment: ""- - text: c1- type: COLUMN- definition: ""- comment: ""- input: SELECT cc1.| FROM t1 cc1 JOIN t2 on NOT cc1.c1 = t2.c1want:- text: c1@@ -248,6 +248,10 @@comment: ""- input: SELECT | FROM t1 xwant:+ - text: c1+ type: COLUMN+ definition: public.t1 | int, NOT NULL+ comment: ""- text: publictype: SCHEMAdefinition: ""@@ -268,12 +272,12 @@type: VIEWdefinition: ""comment: ""+- input: SELECT | FROM public.t1+ want:- text: c1type: COLUMNdefinition: public.t1 | int, NOT NULLcomment: ""-- input: SELECT | FROM public.t1- want:- text: publictype: SCHEMAdefinition: ""@@ -290,7 +294,3 @@type: VIEWdefinition: ""comment: ""- - text: c1- type: COLUMN- definition: public.t1 | int, NOT NULL- comment: ""diff --git a/backend/plugin/parser/plsql/completion_test.go b/backend/plugin/parser/plsql/completion_test.goindex 19ab87f446..2463cf1717 100644--- a/backend/plugin/parser/plsql/completion_test.go+++ b/backend/plugin/parser/plsql/completion_test.go@@ -4,6 +4,7 @@ import ("context""io""os"+ "sort""testing""github.com/stretchr/testify/require"@@ -56,6 +57,16 @@ func TestCompletion(t *testing.T) {filteredResult = append(filteredResult, r)}}+ sort.Slice(filteredResult, func(i, j int) bool {+ if filteredResult[i].Type != filteredResult[j].Type {+ return filteredResult[i].Type < filteredResult[j].Type+ }+ if filteredResult[i].Text != filteredResult[j].Text {+ return filteredResult[i].Text < filteredResult[j].Text+ }+ return filteredResult[i].Definition < filteredResult[j].Definition+ })+if record {tests[i].Want = filteredResult} else {diff --git a/backend/plugin/parser/plsql/test-data/test_completion.yaml b/backend/plugin/parser/plsql/test-data/test_completion.yamlindex 5bda6a66ee..6c25206f75 100644--- a/backend/plugin/parser/plsql/test-data/test_completion.yaml+++ b/backend/plugin/parser/plsql/test-data/test_completion.yaml@@ -58,6 +58,14 @@comment: ""- input: WITH x(x1, x2) AS (SELECT * FROM t2) SELECT | FROM xwant:+ - text: X1+ type: COLUMN+ definition: ""+ comment: ""+ - text: X2+ type: COLUMN+ definition: ""+ comment: ""- text: SCHEMA1type: SCHEMAdefinition: ""@@ -82,20 +90,28 @@type: TABLEdefinition: ""comment: ""- - text: X1- type: COLUMN+ - text: V1+ type: VIEWdefinition: ""comment: ""- - text: X2+- input: SELECT c1 as eid, c2 as xid FROM t2 GROUP BY |+ want:+ - text: C1+ type: COLUMN+ definition: SCHEMA1.T2 | int, NOT NULL+ comment: ""+ - text: C2+ type: COLUMN+ definition: SCHEMA1.T2 | int, NOT NULL+ comment: ""+ - text: EIDtype: COLUMNdefinition: ""comment: ""- - text: V1- type: VIEW+ - text: XID+ type: COLUMNdefinition: ""comment: ""-- input: SELECT c1 as eid, c2 as xid FROM t2 GROUP BY |- want:- text: SCHEMA1type: SCHEMAdefinition: ""@@ -116,6 +132,12 @@type: TABLEdefinition: ""comment: ""+ - text: V1+ type: VIEW+ definition: ""+ comment: ""+- input: SELECT c1 as eid, c2 as xid FROM t2 ORDER BY |+ want:- text: C1type: COLUMNdefinition: SCHEMA1.T2 | int, NOT NULL@@ -132,12 +154,6 @@type: COLUMNdefinition: ""comment: ""- - text: V1- type: VIEW- definition: ""- comment: ""-- input: SELECT c1 as eid, c2 as xid FROM t2 ORDER BY |- want:- text: SCHEMA1type: SCHEMAdefinition: ""@@ -158,28 +174,20 @@type: TABLEdefinition: ""comment: ""- - text: C1- type: COLUMN- definition: SCHEMA1.T2 | int, NOT NULL+ - text: V1+ type: VIEW+ definition: ""comment: ""- - text: C2+- input: SELECT c1 as eid FROM t1 ORDER BY |+ want:+ - text: C1type: COLUMN- definition: SCHEMA1.T2 | int, NOT NULL+ definition: SCHEMA1.T1 | int, NOT NULLcomment: ""- text: EIDtype: COLUMNdefinition: ""comment: ""- - text: XID- type: COLUMN- definition: ""- comment: ""- - text: V1- type: VIEW- definition: ""- comment: ""-- input: SELECT c1 as eid FROM t1 ORDER BY |- want:- text: SCHEMA1type: SCHEMAdefinition: ""@@ -200,14 +208,6 @@type: TABLEdefinition: ""comment: ""- - text: C1- type: COLUMN- definition: SCHEMA1.T1 | int, NOT NULL- comment: ""- - text: EID- type: COLUMN- definition: ""- comment: ""- text: V1type: VIEWdefinition: ""@@ -216,6 +216,10 @@SELECT FROM basdkfjasldf;SELECT | FROM t1want:+ - text: C1+ type: COLUMN+ definition: SCHEMA1.T1 | int, NOT NULL+ comment: ""- text: SCHEMA1type: SCHEMAdefinition: ""@@ -236,16 +240,20 @@type: TABLEdefinition: ""comment: ""- - text: C1- type: COLUMN- definition: SCHEMA1.T1 | int, NOT NULL- comment: ""- text: V1type: VIEWdefinition: ""comment: ""- input: SELECT | FROM (SELECT c1 FROM t1) cc1want:+ - text: C1+ type: COLUMN+ definition: ""+ comment: ""+ - text: C1+ type: COLUMN+ definition: SCHEMA1.T1 | int, NOT NULL+ comment: ""- text: SCHEMA1type: SCHEMAdefinition: ""@@ -270,14 +278,6 @@type: TABLEdefinition: ""comment: ""- - text: C1- type: COLUMN- definition: ""- comment: ""- - text: C1- type: COLUMN- definition: SCHEMA1.T1 | int, NOT NULL- comment: ""- text: V1type: VIEWdefinition: ""@@ -352,6 +352,10 @@comment: ""- input: SELECT | FROM t1 xwant:+ - text: C1+ type: COLUMN+ definition: SCHEMA1.T1 | int, NOT NULL+ comment: ""- text: SCHEMA1type: SCHEMAdefinition: ""@@ -376,16 +380,16 @@type: TABLEdefinition: ""comment: ""- - text: C1- type: COLUMN- definition: SCHEMA1.T1 | int, NOT NULL- comment: ""- text: V1type: VIEWdefinition: ""comment: ""- input: SELECT | FROM schema1.t1want:+ - text: C1+ type: COLUMN+ definition: SCHEMA1.T1 | int, NOT NULL+ comment: ""- text: SCHEMA1type: SCHEMAdefinition: ""@@ -406,10 +410,6 @@type: TABLEdefinition: ""comment: ""- - text: C1- type: COLUMN- definition: SCHEMA1.T1 | int, NOT NULL- comment: ""- text: V1type: VIEWdefinition: ""