diff --git a/spec/datadog/ci/configuration/components_spec.rb b/spec/datadog/ci/configuration/components_spec.rb index 762898c1..80a71f7d 100644 --- a/spec/datadog/ci/configuration/components_spec.rb +++ b/spec/datadog/ci/configuration/components_spec.rb @@ -112,7 +112,7 @@ context "when api key is set" do let(:api_key) { "api_key" } - it "sets async for test mode and provides transport and shutdown timeout to the write" do + it "sets async for test mode and provides transport and shutdown timeout to the writer" do expect(settings.tracing.test_mode) .to have_received(:async=) .with(true) @@ -120,46 +120,6 @@ expect(settings.tracing.test_mode).to have_received(:writer_options=) do |options| expect(options[:transport]).to be_kind_of(Datadog::CI::TestVisibility::Transport) expect(options[:shutdown_timeout]).to eq(60) - - api = options[:transport].api - expect(api.api_key).to eq(api_key) - - http_client = api.http - expect(http_client.host).to eq("citestcycle-intake.datadoghq.com") - expect(http_client.port).to eq(443) - expect(http_client.ssl).to eq(true) - end - end - - context "when agentless_url is provided" do - let(:agentless_url) { "http://localhost:5555" } - - it "configures transport to use intake URL from settings" do - expect(settings.tracing.test_mode).to have_received(:writer_options=) do |options| - api = options[:transport].api - expect(api.api_key).to eq(api_key) - - http_client = api.http - expect(http_client.host).to eq("localhost") - expect(http_client.port).to eq(5555) - expect(http_client.ssl).to eq(false) - end - end - end - - context "when dd_site is provided" do - let(:dd_site) { "eu.datadoghq.com" } - - it "construct intake url using provided host" do - expect(settings.tracing.test_mode).to have_received(:writer_options=) do |options| - api = options[:transport].api - expect(api.api_key).to eq(api_key) - - http_client = api.http - expect(http_client.host).to eq("citestcycle-intake.eu.datadoghq.com") - expect(http_client.port).to eq(443) - expect(http_client.ssl).to eq(true) - end end end end diff --git a/spec/datadog/ci/transport/api/ci_intake_spec.rb b/spec/datadog/ci/transport/api/ci_intake_spec.rb index 3398bc94..bfb6ffca 100644 --- a/spec/datadog/ci/transport/api/ci_intake_spec.rb +++ b/spec/datadog/ci/transport/api/ci_intake_spec.rb @@ -13,16 +13,41 @@ let(:http) { double(:http) } - before do - expect(Datadog::CI::Transport::HTTP).to receive(:new).with( - host: "citestcycle-intake.datad0ghq.com", - port: 443, - ssl: true, - compress: true - ).and_return(http) + describe "#initialize" do + context "with https URL" do + it "creates SSL transport" do + expect(Datadog::CI::Transport::HTTP).to receive(:new).with( + host: "citestcycle-intake.datad0ghq.com", + port: 443, + ssl: true, + compress: true + ).and_return(http) + + subject + end + end + + context "with http URL" do + let(:url) { "http://localhost:5555" } + + it "creates http transport without SSL" do + expect(Datadog::CI::Transport::HTTP).to receive(:new).with( + host: "localhost", + port: 5555, + ssl: false, + compress: true + ).and_return(http) + + subject + end + end end describe "#request" do + before do + allow(Datadog::CI::Transport::HTTP).to receive(:new).and_return(http) + end + it "produces correct headers and forwards request to HTTP layer" do expect(http).to receive(:request).with( path: "path",