-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #87 from momentohq/runtime-version
chore: add agent and runtime-version metadata
- Loading branch information
Showing
6 changed files
with
166 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
defmodule Momento.Internal.ScsControlClientTest do | ||
use ExUnit.Case, async: false | ||
import Mock | ||
|
||
alias Momento.Internal.ScsControlClient | ||
alias Momento.Protos.ControlClient.ScsControl.Stub | ||
|
||
test "agent metadata is only sent on the first call" do | ||
fake_channel = :fake_channel | ||
|
||
client = %ScsControlClient{ | ||
auth_token: "test_token", | ||
channel: fake_channel | ||
} | ||
|
||
with_mock Stub, [:passthrough], | ||
create_cache: fn ^fake_channel, _request, options -> | ||
metadata = Keyword.get(options, :metadata, %{}) | ||
send(self(), {:grpc_call, metadata}) | ||
{:ok, %{}} | ||
end do | ||
ScsControlClient.create_cache(client, "test_cache") | ||
assert_received {:grpc_call, metadata} | ||
assert Map.has_key?(metadata, "agent") | ||
assert Map.has_key?(metadata, "runtime-version") | ||
|
||
ScsControlClient.create_cache(client, "test_cache") | ||
assert_received {:grpc_call, metadata} | ||
refute Map.has_key?(metadata, "agent") | ||
refute Map.has_key?(metadata, "runtime-version") | ||
|
||
ScsControlClient.create_cache(client, "test_cache") | ||
assert_received {:grpc_call, metadata} | ||
refute Map.has_key?(metadata, "agent") | ||
refute Map.has_key?(metadata, "runtime-version") | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
defmodule Momento.Internal.ScsDataClientTest do | ||
use ExUnit.Case, async: false | ||
import Mock | ||
|
||
alias Momento.Internal.ScsDataClient | ||
alias Momento.Protos.CacheClient.Scs.Stub | ||
|
||
test "agent metadata is only sent on the first call" do | ||
fake_channel = :fake_channel | ||
|
||
client = %ScsDataClient{ | ||
auth_token: "test_token", | ||
channel: fake_channel | ||
} | ||
|
||
with_mock Stub, [:passthrough], | ||
set: fn ^fake_channel, _request, options -> | ||
metadata = Keyword.get(options, :metadata, %{}) | ||
send(self(), {:grpc_call, metadata}) | ||
{:ok, %{}} | ||
end do | ||
ScsDataClient.set(client, "test_cache", "key1", "value1", 60) | ||
assert_received {:grpc_call, metadata} | ||
assert Map.has_key?(metadata, "agent") | ||
assert Map.has_key?(metadata, "runtime-version") | ||
|
||
ScsDataClient.set(client, "test_cache", "key2", "value2", 60) | ||
assert_received {:grpc_call, metadata} | ||
refute Map.has_key?(metadata, "agent") | ||
refute Map.has_key?(metadata, "runtime-version") | ||
|
||
ScsDataClient.set(client, "test_cache", "key3", "value3", 60) | ||
assert_received {:grpc_call, metadata} | ||
refute Map.has_key?(metadata, "agent") | ||
refute Map.has_key?(metadata, "runtime-version") | ||
end | ||
end | ||
end |