spec/cli_spec.rb in gitlab-exporter-14.0.0 vs spec/cli_spec.rb in gitlab-exporter-14.1.0
- old
+ new
@@ -1,7 +1,8 @@
require "spec_helper"
require "gitlab_exporter/cli"
+require "optparse"
context "With valid pair of repositories" do
let(:repos) { GitRepoBuilder.new }
after do
@@ -24,8 +25,54 @@
args = CLIArgs.new([repos.cloned_repo, output])
ssh = GitLab::Exporter::CLI::GIT.new(args)
ssh.run
output.rewind
expect(output.read).to match(/git_push_time_milliseconds \d+ \d+/)
+ end
+ end
+end
+
+describe GitLab::Exporter::CLI::Server do
+ context "extra-config-command is passed" do
+ let(:argv) do
+ ["-c", "spec/fixtures/config.yml", "--extra-config-command", extra_config_command]
+ .extend(OptionParser::Arguable)
+ end
+ let(:extra_config_command) { "vault kv get top-secrets" }
+ let(:server_cmd) { described_class.new(argv) }
+
+ before do
+ allow(server_cmd).to receive(:run_extra_config_command).and_return(<<~YAML
+ probes:
+ sidekiq:
+ methods:
+ - probe_workers
+ opts:
+ redis_url: redis://hunter1@localhost:9765
+ database:
+ opts:
+ connection_string: postgres://db-admin:hunter1@localhost:6543/main-db
+ YAML
+ )
+ end
+
+ it "merges the returned YAML from the command with the passed config" do
+ expect(server_cmd.merged_config).to eq({
+ probes: {
+ sidekiq: {
+ methods: %w[probe_stats probe_workers],
+ opts: {
+ redis_url: "redis://hunter1@localhost:9765"
+ }
+ },
+ database: {
+ methods: ["probe_db"],
+ opts: {
+ connection_string:
+ "postgres://db-admin:hunter1@localhost:6543/main-db"
+ }
+ }
+ }
+ })
end
end
end