Do not record duplicate queries into history

This commit is contained in:
Dan Sosedoff
2016-01-07 20:55:23 -06:00
parent 1bc824e39b
commit 9b5764d4fb
2 changed files with 26 additions and 3 deletions

View File

@@ -244,11 +244,11 @@ func test_ResultCsv(t *testing.T) {
}
func test_History(t *testing.T) {
_, err := testClient.Query("SELECT * FROM books")
_, err := testClient.Query("SELECT * FROM books WHERE id = 12345")
query := testClient.History[len(testClient.History)-1].Query
assert.Equal(t, nil, err)
assert.Equal(t, "SELECT * FROM books", query)
assert.Equal(t, "SELECT * FROM books WHERE id = 12345", query)
}
func test_HistoryError(t *testing.T) {
@@ -259,6 +259,16 @@ func test_HistoryError(t *testing.T) {
assert.NotEqual(t, "SELECT * FROM books123", query)
}
func test_HistoryUniqueness(t *testing.T) {
client, _ := NewFromUrl("postgres://postgres@localhost/booktown?sslmode=disable")
client.Query("SELECT * FROM books WHERE id = 1")
client.Query("SELECT * FROM books WHERE id = 1")
assert.Equal(t, 1, len(client.History))
assert.Equal(t, "SELECT * FROM books WHERE id = 1", client.History[0].Query)
}
func TestAll(t *testing.T) {
if onWindows() {
// Dont have access to windows machines at the moment...