Skip to content

Commit 2557c2e

Browse files
committed
Add some basic tests for Provider
1 parent 7585c4d commit 2557c2e

File tree

4 files changed

+376
-8
lines changed

4 files changed

+376
-8
lines changed

lib/datadog/open_feature/provider.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ module OpenFeature
2121
# client.fetch_string_value(flag_key: 'banner', default_value: 'default')
2222
class Provider
2323
NAME = 'Datadog Feature Flagging Provider'
24+
PROVIDER_FATAL = 'PROVIDER_FATAL'
2425
ERROR_MESSAGE_COMPONENT_NOT_CONFIGURED = "Datadog's OpenFeature component must be configured"
2526

2627
attr_reader :metadata
@@ -87,7 +88,7 @@ def evaluate(flag_key, default_value:, expected_type:, evaluation_context:)
8788
def component_not_configured_default(value)
8889
::OpenFeature::SDK::Provider::ResolutionDetails.new(
8990
value: value,
90-
error_code: ::OpenFeature::SDK::Provider::ErrorCode::PROVIDER_FATAL,
91+
error_code: PROVIDER_FATAL,
9192
error_message: ERROR_MESSAGE_COMPONENT_NOT_CONFIGURED,
9293
reason: ::OpenFeature::SDK::Provider::Reason::ERROR
9394
)

sig/datadog/open_feature/evaluator.rbs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,12 @@ module Datadog
2525
) -> instance
2626
end
2727

28-
class Configuration
29-
@json: ::String
28+
class Evaluator
29+
@ufc_json: ::String
3030

31-
def initialize: (::String json) -> void
32-
end
31+
def initialize: (::String ufc_json) -> void
3332

34-
module Functions
35-
def self.get_assignment: (
33+
def get_assignment: (
3634
Configuration configuration,
3735
::String flag_key,
3836
untyped evaluation_context,
@@ -42,7 +40,7 @@ module Datadog
4240

4341
private
4442

45-
def self.generate: (::Symbol expected_type) -> untyped
43+
def generate: (::Symbol expected_type) -> untyped
4644
end
4745
end
4846

sig/datadog/open_feature/provider.rbs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,11 @@ module Datadog
22
module OpenFeature
33
class Provider
44
NAME: ::String
5+
56
ERROR_MESSAGE_COMPONENT_NOT_CONFIGURED: ::String
67

8+
PROVIDER_FATAL: ::String
9+
710
attr_reader metadata: ::OpenFeature::SDK::Provider::ProviderMetadata
811

912
def initialize: () -> void

0 commit comments

Comments
 (0)