test: close remaining workspace preprocessing gates
This commit is contained in:
@@ -299,10 +299,28 @@ func TestParseWorkspaceAcceptsAssumptionAndEnforcesLimits(t *testing.T) {
|
||||
if _, err := ParseWorkspaceCommand([]string{"workspace", "schema", "suggest-fks", "--workspace", "psd", "--assume", "orders.id=customers.id"}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err := ParseWorkspaceCommand([]string{"workspace", "schema", "suggest-fks", "--workspace", "psd", "--assume", strings.Repeat("a", maxAssumptionBytes+1)}); err == nil {
|
||||
exactAssumption := strings.Repeat("a", 127) + "=" + strings.Repeat("b", 128)
|
||||
if len(exactAssumption) != maxAssumptionBytes {
|
||||
t.Fatalf("test assumption length = %d, want %d", len(exactAssumption), maxAssumptionBytes)
|
||||
}
|
||||
if _, err := ParseWorkspaceCommand([]string{"workspace", "schema", "suggest-fks", "--workspace", "psd", "--assume", exactAssumption}); err != nil {
|
||||
t.Fatalf("rejected exact assumption bound: %v", err)
|
||||
}
|
||||
if _, err := ParseWorkspaceCommand([]string{"workspace", "schema", "suggest-fks", "--workspace", "psd", "--assume", exactAssumption + "a"}); err == nil {
|
||||
t.Fatal("accepted oversized assumption")
|
||||
}
|
||||
args := []string{"workspace", "schema", "suggest-fks", "--workspace", "psd"}
|
||||
for i := 0; i < maxAssumptions; i++ {
|
||||
args = append(args, "--assume", fmt.Sprintf("a%d=b%d", i, i))
|
||||
}
|
||||
if _, err := ParseWorkspaceCommand(args); err != nil {
|
||||
t.Fatalf("rejected exact assumption count: %v", err)
|
||||
}
|
||||
args = append(args, "--assume", "overflow=overflow")
|
||||
if _, err := ParseWorkspaceCommand(args); err == nil {
|
||||
t.Fatalf("accepted %d assumptions", maxAssumptions+1)
|
||||
}
|
||||
args = []string{"workspace", "schema", "suggest-fks", "--workspace", "psd"}
|
||||
for i := 0; i < 33; i++ {
|
||||
args = append(args, "--from-sql", fmt.Sprintf("schema-%d.sql", i))
|
||||
}
|
||||
@@ -368,7 +386,21 @@ func TestWorkspaceIngressAcceptsExactCountsAndByteBounds(t *testing.T) {
|
||||
for i := 0; i < maxAssumptions; i++ {
|
||||
assumptions = append(assumptions, fmt.Sprintf("column_%d=table_%d", i, i))
|
||||
}
|
||||
command := SuggestFksRequest{WorkspaceID: "psd", FromSQL: paths, Assume: assumptions}
|
||||
argv := []string{"workspace", "schema", "suggest-fks", "--workspace", "psd"}
|
||||
for _, path := range paths {
|
||||
argv = append(argv, "--from-sql", path)
|
||||
}
|
||||
for _, assumption := range assumptions {
|
||||
argv = append(argv, "--assume", assumption)
|
||||
}
|
||||
parsed, err := ParseWorkspaceCommand(argv)
|
||||
if err != nil {
|
||||
t.Fatalf("parser rejected exact file/assumption counts: %v", err)
|
||||
}
|
||||
command, ok := parsed.(SuggestFksRequest)
|
||||
if !ok {
|
||||
t.Fatalf("parsed command = %T, want SuggestFksRequest", parsed)
|
||||
}
|
||||
for _, path := range paths {
|
||||
if b, e := safeio.ReadCanonicalUTF8(path, maxSQLFile); e != nil {
|
||||
t.Fatalf("direct read %s: %v", path, e)
|
||||
|
||||
Reference in New Issue
Block a user