-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
decouple API client that requests library settings from ITR
- Loading branch information
1 parent
1f6d3cb
commit 286ed0c
Showing
13 changed files
with
81 additions
and
143 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 was deleted.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
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
6 changes: 3 additions & 3 deletions
6
sig/datadog/ci/itr/client.rbs → sig/datadog/ci/transport/api_client.rbs
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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,41 +1,15 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative "../../../../lib/datadog/ci/itr/client" | ||
require_relative "../../../../lib/datadog/ci/itr/runner" | ||
|
||
RSpec.describe Datadog::CI::ITR::Runner do | ||
let(:itr_enabled) { true } | ||
|
||
let(:api) { double("api") } | ||
let(:client) { double("client") } | ||
subject(:runner) { described_class.new(enabled: itr_enabled) } | ||
|
||
subject(:runner) { described_class.new(enabled: itr_enabled, api: api) } | ||
|
||
describe "#configure" do | ||
let(:service) { "service" } | ||
|
||
context "itr enabled" do | ||
before do | ||
expect(Datadog::CI::ITR::Client).to receive(:new).with(api: api).and_return(client) | ||
end | ||
|
||
it "fetches settings from backend" do | ||
expect(client).to receive(:fetch_settings).with(service: service) | ||
|
||
runner.configure(service: service) | ||
end | ||
end | ||
|
||
context "itr disabled" do | ||
let(:itr_enabled) { false } | ||
|
||
before do | ||
expect(Datadog::CI::ITR::Client).to_not receive(:new) | ||
end | ||
|
||
it "does nothing" do | ||
expect(runner.configure(service: service)).to be_nil | ||
end | ||
describe "#disable" do | ||
it "disables the runner" do | ||
expect { runner.disable }.to change { runner.enabled? }.from(true).to(false) | ||
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
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,31 @@ | ||
require_relative "../../../../lib/datadog/ci/transport/api_client" | ||
|
||
RSpec.describe Datadog::CI::Transport::ApiClient do | ||
let(:api) { spy("api") } | ||
subject { described_class.new(api: api) } | ||
|
||
describe "#fetch_library_settings" do | ||
let(:service) { "service" } | ||
let(:path) { Datadog::CI::Ext::Transport::DD_API_SETTINGS_PATH } | ||
let(:payload) do | ||
{ | ||
data: { | ||
id: "change_me", | ||
type: Datadog::CI::Ext::Transport::DD_API_SETTINGS_TYPE, | ||
attributes: { | ||
service: service | ||
} | ||
} | ||
}.to_json | ||
end | ||
|
||
it "requests the settings" do | ||
subject.fetch_library_settings(service: service) | ||
|
||
expect(api).to have_received(:api_request).with( | ||
path: path, | ||
payload: payload | ||
) | ||
end | ||
end | ||
end |