Skip to content

Commit fe7bf64

Browse files
committed
Add "Readonly" test
1 parent 7d9fcbb commit fe7bf64

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

lib/sqlrunner_test.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,24 @@ func TestDbRunnerQueryTimeout(t *testing.T) {
222222
assert.Equal(t, context.DeadlineExceeded, queryError.Parent)
223223
}
224224

225+
func TestDbRunnerReadonly(t *testing.T) {
226+
t.Parallel()
227+
228+
runner, err := sqlrunner.NewSQLRunner(`
229+
CREATE TABLE readonlytest (
230+
value TEXT
231+
);
232+
233+
INSERT INTO readonlytest (value) VALUES ('hello');
234+
INSERT INTO readonlytest (value) VALUES ('world');
235+
`)
236+
require.NoError(t, err)
237+
238+
_, err = runner.Query(context.TODO(), "INSERT INTO readonlytest (value) VALUES ('test')")
239+
t.Log(err)
240+
require.ErrorAs(t, err, &sqlrunner.QueryError{})
241+
}
242+
225243
func BenchmarkDbrunner(b *testing.B) {
226244
b.ReportAllocs()
227245

0 commit comments

Comments
 (0)