Commit 68b95cd0 authored by Matija Čupić's avatar Matija Čupić

Add CheckGcpProjectBillingWorker

parent 291480f5
class CheckGcpProjectBillingWorker
include ApplicationWorker
def self.redis_shared_state_key_for(token)
"gitlab:gcp:#{token}:billing_enabled"
end
def perform(token)
return unless token
billing_enabled = CheckGcpProjectBillingService.new.execute(token)
Gitlab::Redis::SharedState.with do |redis|
redis.set(self.class.redis_shared_state_key_for(token), billing_enabled)
end
end
end
require 'spec_helper'
describe CheckGcpProjectBillingWorker do
describe '.perform' do
let(:token) { 'bogustoken' }
subject { described_class.new.perform(token) }
it 'calls the service' do
expect(CheckGcpProjectBillingService).to receive_message_chain(:new, :execute)
subject
end
it 'stores billing status in redis' do
expect(CheckGcpProjectBillingService).to receive_message_chain(:new, :execute).and_return(true)
subject
Gitlab::Redis::SharedState.with do |redis|
expect(redis.get("gitlab:gcp:#{token}:billing_enabled")).to eq('true')
end
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment