Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions shard.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ shards:

action-controller:
git: https://github.com/spider-gazelle/action-controller.git
version: 4.10.1
version: 5.1.8

active-model:
git: https://github.com/spider-gazelle/active-model.git
Expand Down Expand Up @@ -81,6 +81,10 @@ shards:
git: https://github.com/luckyframework/habitat.git
version: 0.4.7

hot_topic:
git: https://github.com/jgaskins/hot_topic.git
version: 0.1.0+git.commit.c4577d949221d535f29162343bf503b578308954

http-params-serializable:
git: https://github.com/place-labs/http-params-serializable.git
version: 0.5.0
Expand Down Expand Up @@ -127,19 +131,19 @@ shards:

openssl_ext:
git: https://github.com/spider-gazelle/openssl_ext.git
version: 2.1.5
version: 2.2.0

opentelemetry-api:
git: https://github.com/wyhaines/opentelemetry-api.cr.git
version: 0.5.0

opentelemetry-instrumentation:
git: https://github.com/wyhaines/opentelemetry-instrumentation.cr.git
version: 0.3.6+git.commit.2b4477f57da6b593469deadc3a439e5ed83dd23f
version: 0.5.0+git.commit.7d83b9a53c9540fbc159f06eeed5d4bdad5c4377

opentelemetry-sdk: # Overridden
git: https://github.com/wyhaines/opentelemetry-sdk.cr.git
version: 0.5.0+git.commit.5629aa05bfc0837abe6efd8f19ad28b560d9b6b7
version: 0.5.1+git.commit.857f4dc24e3c4f2ed04b81118b39beccdecdb105

pars: # Overridden
git: https://github.com/spider-gazelle/pars.git
Expand All @@ -151,11 +155,11 @@ shards:

placeos-log-backend:
git: https://github.com/place-labs/log-backend.git
version: 0.11.1
version: 0.11.2

placeos-models:
git: https://github.com/placeos/models.git
version: 8.11.0
version: 8.11.2

protobuf:
git: https://github.com/jeromegn/protobuf.cr.git
Expand Down
2 changes: 1 addition & 1 deletion shard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ targets:
dependencies:
action-controller:
github: spider-gazelle/action-controller
version: ~> 4.4
version: ~> 5.1

awscr-s3:
github: taylorfinnell/awscr-s3
Expand Down
4 changes: 2 additions & 2 deletions spec/helper.cr
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ require "placeos-log-backend"
require "spec"
require "webmock"

# Helper methods for testing controllers (curl, with_server, context)
require "../lib/action-controller/spec/curl_context"
# Helper methods for testing controllers
require "action-controller/spec_helper"

Spec.before_suite do
WebMock.allow_net_connect = true
Expand Down
34 changes: 17 additions & 17 deletions spec/placeos-build/api/driver_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,23 @@ module PlaceOS::Build
describe Api::Driver do
broken_repository_path = "spec/repository_fixtures/broken"
broken_entrypoint = "drivers/place/broken.cr"
with_server do
describe "POST ../:file" do
it "gracefully handles malformed driver" do
tempdir = Dir.tempdir
temporary_repository = File.join(tempdir, Path[broken_repository_path].basename)
FileUtils.cp_r(broken_repository_path, tempdir)
Build.support_local_builds = true
Client.client(URI.parse("http://localhost:6000")) do |client|
client.repository_path = temporary_repository
client.compile(
file: broken_entrypoint,
url: "local",
commit: "abcde",
) do
# This should not be called
true.should be_false
end

describe "POST ../:file" do
it "gracefully handles malformed driver" do
tempdir = Dir.tempdir
temporary_repository = File.join(tempdir, Path[broken_repository_path].basename)
FileUtils.cp_r(broken_repository_path, tempdir)
Build.support_local_builds = true

Client.client(URI.parse("http://localhost:6000"), connection: ActionController::SpecHelper.client) do |client|
client.repository_path = temporary_repository
client.compile(
file: broken_entrypoint,
url: "local",
commit: "abcde",
) do
# This should not be called
true.should be_false
end
end
end
Expand Down
7 changes: 4 additions & 3 deletions src/placeos-build/client.cr
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,21 @@ module PlaceOS::Build
end

# :ditto:
def self.client(uri : URI, build_version : String = BUILD_VERSION)
client = new(uri, build_version)
def self.client(uri : URI, build_version : String = BUILD_VERSION, connection : HTTP::Client? = nil)
client = new(uri, build_version, connection)
begin
yield client
ensure
client.connection.close
end
end

def initialize(uri : URI, @build_version : String = BUILD_VERSION)
def initialize(uri : URI, @build_version : String = BUILD_VERSION, connection : HTTP::Client? = nil)
uri_host = uri.host.presence || raise ArgumentError.new("Could not parse host from URI")
uri_port = uri.port
@host = uri_host
@port = uri_port if uri_port
@connection = connection unless connection.nil?
end

def initialize(host : String? = nil, port : Int32? = nil, @build_version : String = BUILD_VERSION)
Expand Down