-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathtesting_validation.go
More file actions
30 lines (26 loc) · 1007 Bytes
/
testing_validation.go
File metadata and controls
30 lines (26 loc) · 1007 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package plugin
import (
"testing"
"github.com/cloudquery/plugin-sdk/v4/message"
"github.com/cloudquery/plugin-sdk/v4/schema"
)
func ValidateNoEmptyColumns(t *testing.T, tables schema.Tables, messages message.SyncMessages) {
for _, table := range tables.FlattenTables() {
records := messages.GetInserts().GetRecordsForTable(table)
emptyColumns := schema.FindEmptyColumns(table, records)
if len(emptyColumns) > 0 {
t.Fatalf("found empty column(s): %v in %s", emptyColumns, table.Name)
}
}
}
func ValidateSensitiveColumns(t *testing.T, tables schema.Tables) {
for _, table := range tables.FlattenTables() {
nonMatchingColumns, nonMatchingJSONColumns := schema.FindNotMatchingSensitiveColumns(table)
if len(nonMatchingColumns) > 0 {
t.Fatalf("found non-matching sensitive column(s): %v in %s", nonMatchingColumns, table.Name)
}
if len(nonMatchingJSONColumns) > 0 {
t.Fatalf("found non-matching sensitive JSON column(s): %v in %s", nonMatchingJSONColumns, table.Name)
}
}
}