MCPcopy Create free account
hub / github.com/bytebase/bytebase / TestGetQueryExportFactors

Function TestGetQueryExportFactors

backend/common/cel_test.go:76–116  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

74}
75
76func TestGetQueryExportFactors(t *testing.T) {
77 a := assert.New(t)
78 tests := []struct {
79 expression string
80 want QueryExportFactors
81 }{
82 {
83 expression: "request.time < timestamp(\"2023-07-04T06:09:03.384Z\") && (resource.database == \"instances/postgres-sample/databases/employee\" && resource.schema_name == \"public\" && resource.table_name in [\"dept_manager\"])",
84 want: QueryExportFactors{
85 Databases: []string{"instances/postgres-sample/databases/employee"},
86 },
87 },
88 {
89 expression: "request.time < timestamp(\"2023-07-04T07:40:05.658Z\") && (resource.database in [\"instances/postgres-sample/databases/employee\"])",
90 want: QueryExportFactors{
91 Databases: []string{"instances/postgres-sample/databases/employee"},
92 },
93 },
94 {
95 expression: "request.time < timestamp(\"2023-08-02T07:33:45.686Z\") && (resource.database == \"instances/postgres-sample/databases/employee\" && resource.schema_name == \"public\" && resource.table_name in [\"dept_emp\",\"department\"])",
96 want: QueryExportFactors{
97 Databases: []string{"instances/postgres-sample/databases/employee"},
98 },
99 },
100 {
101 expression: "request.time < timestamp(\"2023-07-10T08:14:34.788Z\")",
102 want: QueryExportFactors{},
103 },
104 {
105 expression: "request.time < timestamp(\"2023-07-10T08:15:46.773Z\") && ((resource.database in [\"instances/postgres-sample/databases/blog\"]) || (resource.database == \"instances/postgres-sample/databases/employee\" && resource.schema_name in [\"public\"]))",
106 want: QueryExportFactors{
107 Databases: []string{"instances/postgres-sample/databases/blog", "instances/postgres-sample/databases/employee"},
108 },
109 },
110 }
111 for _, tt := range tests {
112 factors, err := GetQueryExportFactors(tt.expression)
113 a.NoError(err)
114 a.Equal(tt.want, *factors)
115 }
116}
117
118func TestFallbackApprovalFactors(t *testing.T) {
119 a := require.New(t)

Callers

nothing calls this directly

Calls 2

GetQueryExportFactorsFunction · 0.85
EqualMethod · 0.65

Tested by

no test coverage detected