Merge pull request #193 from sosedoff/read-only-mode

Read only mode
This commit is contained in:
Dan Sosedoff
2016-11-05 21:29:30 -05:00
committed by GitHub
4 changed files with 46 additions and 0 deletions

View File

@@ -333,6 +333,18 @@ func test_HistoryUniqueness(t *testing.T) {
assert.Equal(t, "SELECT * FROM books WHERE id = 1", client.History[0].Query)
}
func test_ReadOnlyMode(t *testing.T) {
url := fmt.Sprintf("postgres://%s@%s:%s/%s?sslmode=disable", serverUser, serverHost, serverPort, serverDatabase)
client, _ := NewFromUrl(url, nil)
err := client.SetReadOnlyMode()
assert.Equal(t, nil, err)
_, err = client.Query("CREATE TABLE foobar(id integer);")
assert.NotNil(t, err)
assert.Contains(t, err.Error(), "in a read-only transaction")
}
func TestAll(t *testing.T) {
if onWindows() {
t.Log("Unit testing on Windows platform is not supported.")
@@ -361,7 +373,9 @@ func TestAll(t *testing.T) {
test_TableRowsOrderEscape(t)
test_ResultCsv(t)
test_History(t)
test_HistoryUniqueness(t)
test_HistoryError(t)
test_ReadOnlyMode(t)
teardownClient()
teardown()