feat: added a test for table max capacity
This commit is contained in:
+24
-1
@@ -35,15 +35,21 @@ func runner(commands []string, t *testing.T) []string {
|
|||||||
go func() {
|
go func() {
|
||||||
defer stdin.Close()
|
defer stdin.Close()
|
||||||
for _, c := range commands {
|
for _, c := range commands {
|
||||||
_, _ = io.WriteString(stdin, c+"\n")
|
_, err = io.WriteString(stdin, c+"\n")
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("Failed to execute %v because of %q\n", c, err)
|
||||||
|
break
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
reader := bufio.NewReader(stdout)
|
reader := bufio.NewReader(stdout)
|
||||||
for {
|
for {
|
||||||
|
// fmt.Printf("reading command outputs...\n")
|
||||||
line, err := reader.ReadString('\n')
|
line, err := reader.ReadString('\n')
|
||||||
if line != "" {
|
if line != "" {
|
||||||
formattedline := fmt.Sprintf("%v", strings.Trim(strings.ReplaceAll(line, "\x00", ""), "\n"))
|
formattedline := fmt.Sprintf("%v", strings.Trim(strings.ReplaceAll(line, "\x00", ""), "\n"))
|
||||||
|
// fmt.Printf("formatting and appending result: %v\n", formattedline)
|
||||||
results = append(results, formattedline)
|
results = append(results, formattedline)
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -83,3 +89,20 @@ func TestMain(t *testing.T) {
|
|||||||
t.Errorf("Output Mismatch\nExpected: %v\nGot: %v\n", expected, results)
|
t.Errorf("Output Mismatch\nExpected: %v\nGot: %v\n", expected, results)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestTableFull(t *testing.T) {
|
||||||
|
maxRows := 1400
|
||||||
|
commands := make([]string, 0)
|
||||||
|
|
||||||
|
for i := range maxRows {
|
||||||
|
c := fmt.Sprintf("insert %d user%d person%d@example.com", i, i, i)
|
||||||
|
commands = append(commands, c)
|
||||||
|
}
|
||||||
|
commands = append(commands, ".exit")
|
||||||
|
|
||||||
|
results := runner(commands, t)
|
||||||
|
|
||||||
|
if results[1300] != "godb > Error: Table is full" {
|
||||||
|
t.Errorf("Our Tables max capacity is 1300 rows, but we're able to insert %v\n", len(results))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user