Skip to content

Commit

Permalink
fix factory tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tyiuhc committed Jul 29, 2024
1 parent 115dbd9 commit 6275e02
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 10 deletions.
13 changes: 13 additions & 0 deletions lib/experiment/test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
require 'amplitude-experiment'
module AmplitudeExperiment
API_KEY = 'server-qz35UwzJ5akieoAdIgzM4m9MIiOLXLoz'.freeze
test_user = User.new(user_id: '[email protected]', device_id: 'device', groups: { 'org id' => ['1'] })
assignment_config = AssignmentConfig.new('a6dd847b9d2f03c816d4f3f8458cdc1d')
#cohort_sync_config = CohortSyncConfig.new('a6dd847b9d2f03c816d4f3f8458cdc1d', '15e318eb49bc1a78b5afac2ec975dda2')
local_client = LocalEvaluationClient.new(API_KEY, LocalEvaluationConfig.new(debug: true,
#cohort_sync_config: cohort_sync_config,
assignment_config: assignment_config))
local_client.start
results_local = local_client.evaluate(test_user)
puts results_local
end
9 changes: 4 additions & 5 deletions spec/experiment/local/factory_spec.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
API_KEY = 'client-DvWljIjiiuqLbyjqdvBaLFfEBrAvGuA3'.freeze

describe AmplitudeExperiment do
let(:api_key) { 'client-DvWljIjiiuqLbyjqdvBaLFfEBrAvGuA3' }
describe '#init' do
it 'test hold a singleton instance for local evaluation client' do
client1 = AmplitudeExperiment.initialize_local(API_KEY)
client2 = AmplitudeExperiment.initialize_local(API_KEY)
client1 = AmplitudeExperiment.initialize_local(api_key)
client2 = AmplitudeExperiment.initialize_local(api_key)
expect(client1).to equal client2
end
it 'test hold a different instance for different api keys' do
client1 = AmplitudeExperiment.initialize_local(API_KEY)
client1 = AmplitudeExperiment.initialize_local(api_key)
client2 = AmplitudeExperiment.initialize_local('different-api-key')
expect(client1).not_to equal client2
end
Expand Down
9 changes: 4 additions & 5 deletions spec/experiment/remote/factory_spec.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
API_KEY = 'client-DvWljIjiiuqLbyjqdvBaLFfEBrAvGuA3'.freeze

describe AmplitudeExperiment do
let(:api_key) { 'client-DvWljIjiiuqLbyjqdvBaLFfEBrAvGuA3' }
describe '#init' do
it 'test hold a singleton instance for remote evaluation client' do
client1 = AmplitudeExperiment.initialize_remote(API_KEY)
client2 = AmplitudeExperiment.initialize_remote(API_KEY)
client1 = AmplitudeExperiment.initialize_remote(api_key)
client2 = AmplitudeExperiment.initialize_remote(api_key)
expect(client1).to equal client2
end
it 'test hold a different instance for different api keys' do
client1 = AmplitudeExperiment.initialize_remote(API_KEY)
client1 = AmplitudeExperiment.initialize_remote(api_key)
client2 = AmplitudeExperiment.initialize_remote('different-api-key')
expect(client1).not_to equal client2
end
Expand Down

0 comments on commit 6275e02

Please sign in to comment.