diff options
author | Hubert Chathi <hubert@uhoreg.ca> | 2019-10-06 09:21:43 -0400 |
---|---|---|
committer | Hubert Chathi <hubert@uhoreg.ca> | 2019-10-06 09:22:10 -0400 |
commit | b1ac9384a8c84e72bd42f30893b7c523f22b2049 (patch) | |
tree | 8b982d4234337c742efabcd1d48c87fe7af822cd /test/polyjuice | |
parent | add support for filters (diff) |
add test for Ets storage (and fix some issues)
Diffstat (limited to 'test/polyjuice')
-rw-r--r-- | test/polyjuice/client/storage/ets_test.exs | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/test/polyjuice/client/storage/ets_test.exs b/test/polyjuice/client/storage/ets_test.exs new file mode 100644 index 0000000..115c757 --- /dev/null +++ b/test/polyjuice/client/storage/ets_test.exs @@ -0,0 +1,54 @@ +# Copyright 2019 Hubert Chathi <hubert@uhoreg.ca> +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +defmodule Polyjuice.Client.Storage.EtsTest do + use ExUnit.Case + alias Polyjuice.Client.Storage + alias Polyjuice.Client.Filter + + test "ets" do + ets = Storage.Ets.open() + + assert Storage.get_sync_token(ets) == nil + + Storage.set_sync_token(ets, "token") + assert Storage.get_sync_token(ets) == "token" + + Storage.set_sync_token(ets, "token2") + assert Storage.get_sync_token(ets) == "token2" + + assert Storage.get_filter_id(ets, %{}) == nil + + Storage.set_filter_id(ets, %{}, "filterid1") + assert Storage.get_filter_id(ets, %{}) == "filterid1" + + assert Storage.get_filter_id(ets, Filter.lazy_loading()) == nil + + Storage.set_filter_id(ets, Filter.lazy_loading(), "filterid2") + assert Storage.get_filter_id(ets, Filter.lazy_loading()) == "filterid2" + assert Storage.get_filter_id(ets, %{}) == "filterid1" + + assert Storage.kv_get(ets, "key1") == nil + assert Storage.kv_get(ets, "key1", :default) == :default + + Storage.kv_put(ets, "key1", "value1") + assert Storage.kv_get(ets, "key1") == "value1" + + Storage.kv_put(ets, "key2", "value2") + assert Storage.kv_get(ets, "key2") == "value2" + assert Storage.kv_get(ets, "key1") == "value1" + + Storage.close(ets) + end +end |