fix: #9 no error on trying to insert more than limit, plus some other
tests and minor fix
This commit is contained in:
@@ -106,3 +106,31 @@ func TestTableFull(t *testing.T) {
|
||||
t.Errorf("Our Tables max capacity is 1300 rows, but we're able to insert %v\n", len(results))
|
||||
}
|
||||
}
|
||||
|
||||
func TestMaxLengthForValues(t *testing.T) {
|
||||
commands := []string{"insert 0 " + strings.Repeat("n", 32) + " " + strings.Repeat("n", 255), ".exit"}
|
||||
expected := []string{"godb > Executed.", "godb > bye!"}
|
||||
|
||||
results := runner(commands, t)
|
||||
for i := range results {
|
||||
results[i] = strings.ReplaceAll(results[i], "\n", "")
|
||||
}
|
||||
|
||||
if !slices.Equal(expected, results) {
|
||||
t.Errorf("Output Mismatch\nExpected: %v\nGot: %v\n", expected, results)
|
||||
}
|
||||
}
|
||||
|
||||
func TestOverMaxLengthValues(t *testing.T) {
|
||||
commands := []string{"insert 0 " + strings.Repeat("n", 42) + " " + strings.Repeat("n", 275), ".exit"}
|
||||
expected := []string{"godb > Values for either username or email are too long", "godb > bye!"}
|
||||
|
||||
results := runner(commands, t)
|
||||
for i := range results {
|
||||
results[i] = strings.ReplaceAll(results[i], "\n", "")
|
||||
}
|
||||
|
||||
if !slices.Equal(expected, results) {
|
||||
t.Errorf("Output Mismatch\nExpected: %v\nGot: %v\n", expected, results)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user