-
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.
- Loading branch information
1 parent
f8e5691
commit cc7ae6d
Showing
6 changed files
with
67 additions
and
6 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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative "git" | ||
|
||
module Datadog | ||
module CI | ||
module Utils | ||
module Configuration | ||
def self.fetch_service_name(default) | ||
Datadog.configuration.service_without_fallback || Git.repository_name || default | ||
end | ||
end | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module Datadog | ||
module CI | ||
module Utils | ||
module Configuration | ||
def self.fetch_service_name: (String default) -> String | ||
end | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
RSpec.describe ::Datadog::CI::Utils::Configuration do | ||
describe ".fetch_service_name" do | ||
subject { described_class.fetch_service_name(default) } | ||
|
||
let(:default) { "default" } | ||
|
||
before do | ||
allow(::Datadog.configuration).to receive(:service_without_fallback).and_return(service) | ||
end | ||
|
||
context "when service is set in Datadog config" do | ||
let(:service) { "service_without_fallback" } | ||
|
||
it { is_expected.to eq(service) } | ||
end | ||
|
||
context "when service is not set" do | ||
let(:service) { nil } | ||
|
||
before do | ||
expect(::Datadog::CI::Utils::Git).to receive(:repository_name).and_return(repository_name) | ||
end | ||
|
||
context "when repository_name can be fetched" do | ||
let(:repository_name) { "repository_name" } | ||
|
||
it { is_expected.to eq(repository_name) } | ||
end | ||
|
||
context "when repository_name can not be fetched" do | ||
let(:repository_name) { nil } | ||
|
||
it { is_expected.to eq(default) } | ||
end | ||
end | ||
end | ||
end |