File tree Expand file tree Collapse file tree 3 files changed +39
-3
lines changed
test/nebulex_redis_adapter Expand file tree Collapse file tree 3 files changed +39
-3
lines changed Original file line number Diff line number Diff line change 4444 - uses : actions/checkout@v3
4545
4646 - name : Start Docker
47- run : docker- compose up --detach
47+ run : docker compose up --detach
4848
4949 - name : Install OTP and Elixir
5050 uses : erlef/setup-beam@v1
Original file line number Diff line number Diff line change @@ -3,11 +3,46 @@ defmodule NebulexRedisAdapter.Serializer.SerializableTest do
33
44 alias NebulexRedisAdapter.Serializer.Serializable
55
6+ defmodule Cache do
7+ use Nebulex.Cache ,
8+ otp_app: :nebulex_redis_adapter ,
9+ adapter: NebulexRedisAdapter
10+ end
11+
612 describe "encode/2" do
713 test "error: raises Protocol.UndefinedError exception" do
814 assert_raise Protocol.UndefinedError , ~r" cannot encode a bitstring to a string" , fn ->
915 Serializable . encode ( << 1 :: 1 >> )
1016 end
1117 end
1218 end
19+
20+ describe "encode/decode" do
21+ setup do
22+ { :ok , pid } = Cache . start_link ( )
23+
24+ on_exit ( fn ->
25+ :ok = Process . sleep ( 100 )
26+
27+ if Process . alive? ( pid ) , do: Cache . stop ( pid )
28+ end )
29+
30+ { :ok , cache: Cache , name: Cache }
31+ end
32+
33+ test "anonymous function is stored and then returned (not evaluated)" do
34+ fun = fn _x , _y ->
35+ _ = send ( self ( ) , "Hi!" )
36+
37+ { :cont , [ ] }
38+ end
39+
40+ assert Cache . put ( "fun" , fun ) == :ok
41+ assert value = Cache . get ( "fun" )
42+ assert is_function ( value , 2 )
43+ assert value == fun
44+ assert Enum . to_list ( value ) == [ ]
45+ assert_receive "Hi!"
46+ end
47+ end
1348end
Original file line number Diff line number Diff line change @@ -6,11 +6,12 @@ defmodule NebulexRedisAdapter.StandaloneTest do
66
77 setup do
88 { :ok , pid } = Cache . start_link ( )
9- Cache . delete_all ( )
10- :ok
9+
10+ _ = Cache . delete_all ( )
1111
1212 on_exit ( fn ->
1313 :ok = Process . sleep ( 100 )
14+
1415 if Process . alive? ( pid ) , do: Cache . stop ( pid )
1516 end )
1617
You can’t perform that action at this time.
0 commit comments