Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion temporalio/lib/temporalio/env_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ def to_h
# Create a client connect config from this profile
# @return [Array] Tuple of [positional_args, keyword_args] that can be splatted to Client.connect
def to_client_connect_options
positional_args = [address, namespace].compact
positional_args = [address, namespace]
tls_value = false
if tls
tls_value = tls.to_client_tls_options
Expand Down
32 changes: 31 additions & 1 deletion temporalio/test/envconfig_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class EnvConfigTest < Test
TOML

# =============================================================================
# PROFILE LOADING TESTS (6 tests)
# PROFILE LOADING TESTS (7 tests)
# =============================================================================

def test_load_profile_from_file_default
Expand Down Expand Up @@ -184,6 +184,36 @@ def test_load_profile_env_overrides
end
end

def test_to_client_connect_options_preserves_nil_values
# Test that nil values in address/namespace are preserved in positional_args
profile_no_address = Temporalio::EnvConfig::ClientConfigProfile.new(
address: nil,
namespace: 'my-namespace'
)
args, = profile_no_address.to_client_connect_options
assert_equal 2, args.length, 'positional_args should always have exactly 2 elements'
assert_nil args[0], 'address should be nil in first position (not removed)'
assert_equal 'my-namespace', args[1], 'namespace should be in second position'

profile_both_nil = Temporalio::EnvConfig::ClientConfigProfile.new(
address: nil,
namespace: nil
)
args, = profile_both_nil.to_client_connect_options
assert_equal 2, args.length, 'positional_args should always have exactly 2 elements'
assert_nil args[0], 'address should be nil in first position'
assert_nil args[1], 'namespace should be nil in second position'

profile_both_present = Temporalio::EnvConfig::ClientConfigProfile.new(
address: 'my-address:7233',
namespace: 'my-namespace'
)
args, = profile_both_present.to_client_connect_options
assert_equal 2, args.length, 'positional_args should always have exactly 2 elements'
assert_equal 'my-address:7233', args[0], 'address should be in first position'
assert_equal 'my-namespace', args[1], 'namespace should be in second position'
end

# =============================================================================
# ENVIRONMENT VARIABLES TESTS (4 tests)
# =============================================================================
Expand Down
Loading