Skip to content

Commit

Permalink
Test individual product loading (#3738)
Browse files Browse the repository at this point in the history
Tests that each product can be loaded by itself, and repairs appsec to be loadable without tracing having already been loaded.
  • Loading branch information
p-datadog authored Jun 27, 2024
1 parent d0e0ad5 commit 40c0118
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/datadog/appsec/contrib/sinatra/patcher.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

require_relative '../../../tracing/contrib/rack/middlewares'
require_relative '../../../tracing/contrib'

require_relative '../patcher'
require_relative '../../response'
Expand Down
1 change: 1 addition & 0 deletions lib/datadog/appsec/extensions.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# frozen_string_literal: true

require_relative 'configuration'
require_relative '../core/configuration'

module Datadog
module AppSec
Expand Down
38 changes: 38 additions & 0 deletions spec/loading_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
require 'shellwords'

REQUIRES = {
'datadog/appsec' => 'Datadog::AppSec',
'datadog/core' => 'Datadog::Core',
'datadog/kit' => 'Datadog::Kit',
'datadog/profiling' => 'Datadog::Profiling',
'datadog/tracing' => 'Datadog::Tracing',
}.freeze

RSpec.describe 'loading of products' do
REQUIRES.each do |req, const|
context req do
let(:code) do
<<-E
if defined?(Datadog)
unless Datadog.constants == [:VERSION]
exit 1
end
end
require "#{req}"
unless defined?(#{const})
exit 1
end
exit 0
E
end

it 'loads successfully by itself' do
rv = system("ruby -e #{Shellwords.shellescape(code)}")
expect(rv).to be true
end
end
end
end

0 comments on commit 40c0118

Please sign in to comment.