Skip to content

Commit

Permalink
Run child server for mock testing.
Browse files Browse the repository at this point in the history
  • Loading branch information
TreyE committed Feb 12, 2024
1 parent 375ff5d commit 2ace2b1
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
23 changes: 23 additions & 0 deletions spec/event_source/protocols/sftp/sftp_message_publish_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,27 @@ class SftpProtocolExamplePublishingContext
)
end

let(:server_run_path) do
File.expand_path(
File.join(
File.dirname(__FILE__),
"..",
"..",
"..",
".."
)
)
end

before(:each) do
FileUtils.rm_f(test_file_upload_path)
@sftp_server_pid = spawn(
"bundle exec ruby spec/mock_services/sftp_server.rb",
{
:chdir => server_run_path
}
)
sleep(1)
EventSource::ConnectionManager.instance.drop_connections_for(:http)
EventSource::ConnectionManager.instance.drop_connections_for(:amqp)
EventSource::ConnectionManager.instance.drop_connections_for(:sftp)
Expand All @@ -56,6 +75,10 @@ class SftpProtocolExamplePublishingContext
EventSource.config.load_async_api_resources
end

after(:each) do
Process.kill("INT", @sftp_server_pid)
end

it "can publish a message" do
pub_context = SftpProtocolExamplePublishingContext.new
event = pub_context.event(
Expand Down
2 changes: 1 addition & 1 deletion spec/mock_services/sftp_server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
options = Hash.new

logger = Logger.new(STDOUT)
logger.level = Logger::DEBUG
logger.level = Logger::INFO

auth_password = HrrRbSsh::Authentication::Authenticator.new { |context|
user_and_pass = [
Expand Down

0 comments on commit 2ace2b1

Please sign in to comment.