diff --git a/tests/main_test.go b/tests/main_test.go index 6d4551d..029e0b7 100644 --- a/tests/main_test.go +++ b/tests/main_test.go @@ -35,15 +35,21 @@ func runner(commands []string, t *testing.T) []string { go func() { defer stdin.Close() 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) for { + // fmt.Printf("reading command outputs...\n") line, err := reader.ReadString('\n') if line != "" { formattedline := fmt.Sprintf("%v", strings.Trim(strings.ReplaceAll(line, "\x00", ""), "\n")) + // fmt.Printf("formatting and appending result: %v\n", formattedline) results = append(results, formattedline) } if err != nil { @@ -83,3 +89,20 @@ func TestMain(t *testing.T) { 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)) + } +}