зеркало из https://github.com/github/github-ds.git
add some more tests and fix a typo
This commit is contained in:
Родитель
54ae1b9b3e
Коммит
93c809af88
|
@ -341,7 +341,7 @@ module GitHub
|
|||
# the last insert ID to be the new value.
|
||||
sql.last_insert_id
|
||||
elsif sql.affected_rows == 0 || (found_rows_is_set && sql.affected_rows == 1 && sql.last_insert_id == 0)
|
||||
# No inert took place nor did any update occur. This means that
|
||||
# No insert took place nor did any update occur. This means that
|
||||
# the value was not an integer thus not incremented.
|
||||
raise InvalidValueError
|
||||
elsif sql.affected_rows == 1
|
||||
|
|
|
@ -109,6 +109,29 @@ class GitHub::KVTest < Minitest::Test
|
|||
assert_equal 2, result
|
||||
end
|
||||
|
||||
def test_increment_overwrites_expired_value
|
||||
@kv.set("foo", "100", expires: 1.hour.ago)
|
||||
result = @kv.increment("foo")
|
||||
|
||||
assert_equal 1, result
|
||||
end
|
||||
|
||||
def test_increment_sets_expires
|
||||
expires = 2.hours.from_now.utc
|
||||
|
||||
@kv.set("foo", "100", expires: 1.hour.from_now)
|
||||
@kv.increment("foo", expires: expires)
|
||||
|
||||
assert_equal expires.to_i, @kv.ttl("foo").value!.to_i
|
||||
end
|
||||
|
||||
def test_increment_updates_expires
|
||||
@kv.set("foo", "100", expires: 1.hour.ago)
|
||||
result = @kv.increment("foo")
|
||||
|
||||
assert_equal 1, result
|
||||
end
|
||||
|
||||
def test_increment_non_integer_key_value
|
||||
@kv.set("foo", "bar")
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче