platform files refact
This commit is contained in:
@@ -184,11 +184,11 @@ RSpec.describe "Build configs endpoint", type: :request do
|
||||
|
||||
describe "shipped templates" do
|
||||
it "renders every template to valid YAML with non-empty steps" do
|
||||
templates = Dir[WarpEngine::Engine.root.join("lib/warp_engine/ci_templates/*.yaml.erb")]
|
||||
templates = Dir[WarpEngine::Engine.root.join("app/services/warp_engine/platforms/*/pipeline.yaml.erb")]
|
||||
expect(templates).not_to be_empty
|
||||
|
||||
templates.each do |path|
|
||||
platform = File.basename(path, ".yaml.erb")
|
||||
platform = File.basename(File.dirname(path))
|
||||
allow(WarpEngine.config).to receive(:ci_platforms).and_return(
|
||||
platform => { builder: "registry.example/builder:1", exporter: "registry.example/exporter:1" }
|
||||
)
|
||||
|
||||
@@ -6,8 +6,8 @@ RSpec.describe "POST /build/publish", type: :request do
|
||||
end
|
||||
|
||||
def stub_updater
|
||||
updater = instance_double(WarpEngine::SoftwareUpdater::Tic80Service)
|
||||
allow(WarpEngine::SoftwareUpdater::Tic80Service).to receive(:new).and_return(updater)
|
||||
updater = instance_double(WarpEngine::Platforms::Tic80::Service)
|
||||
allow(WarpEngine::Platforms::Tic80::Service).to receive(:new).and_return(updater)
|
||||
allow(updater).to receive(:update)
|
||||
updater
|
||||
end
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
require "rails_helper"
|
||||
require "zip"
|
||||
|
||||
RSpec.describe WarpEngine::SoftwareUpdater::Tic80Service do
|
||||
RSpec.describe WarpEngine::Platforms::Tic80::Service do
|
||||
let(:tmpdir) { Dir.mktmpdir }
|
||||
let(:name) { "spectic" }
|
||||
let(:version) { "9.9" }
|
||||
@@ -0,0 +1,59 @@
|
||||
require "rails_helper"
|
||||
|
||||
RSpec.describe WarpEngine::PublishService do
|
||||
describe "#publish" do
|
||||
it "raises ArgumentError for unsupported platform" do
|
||||
input = WarpEngine::PublishInputDto.new(platform: "unknown", name: "game", version: "1.0")
|
||||
|
||||
expect { described_class.new.publish(input) }.to raise_error(ArgumentError, /Unsupported platform/)
|
||||
end
|
||||
|
||||
it "routes to correct platform service" do
|
||||
input = WarpEngine::PublishInputDto.new(platform: "tic80", name: "game", version: "1.0")
|
||||
mock_service = instance_double(WarpEngine::Platforms::Tic80::Service)
|
||||
|
||||
allow(WarpEngine::Platforms::Tic80::Service).to receive(:new).and_return(mock_service)
|
||||
allow(mock_service).to receive(:update)
|
||||
|
||||
described_class.new.publish(input)
|
||||
|
||||
expect(mock_service).to have_received(:update).with("game", "1.0")
|
||||
end
|
||||
|
||||
it "routes godot platform to Godot::Service" do
|
||||
input = WarpEngine::PublishInputDto.new(platform: "godot", name: "game", version: "1.0")
|
||||
mock_service = instance_double(WarpEngine::Platforms::Godot::Service)
|
||||
|
||||
allow(WarpEngine::Platforms::Godot::Service).to receive(:new).and_return(mock_service)
|
||||
allow(mock_service).to receive(:update)
|
||||
|
||||
described_class.new.publish(input)
|
||||
|
||||
expect(mock_service).to have_received(:update).with("game", "1.0")
|
||||
end
|
||||
|
||||
it "routes bevy platform to Bevy::Service" do
|
||||
input = WarpEngine::PublishInputDto.new(platform: "bevy", name: "game", version: "1.0")
|
||||
mock_service = instance_double(WarpEngine::Platforms::Bevy::Service)
|
||||
|
||||
allow(WarpEngine::Platforms::Bevy::Service).to receive(:new).and_return(mock_service)
|
||||
allow(mock_service).to receive(:update)
|
||||
|
||||
described_class.new.publish(input)
|
||||
|
||||
expect(mock_service).to have_received(:update).with("game", "1.0")
|
||||
end
|
||||
|
||||
it "routes phaser platform to Phaser::Service" do
|
||||
input = WarpEngine::PublishInputDto.new(platform: "phaser", name: "game", version: "1.0")
|
||||
mock_service = instance_double(WarpEngine::Platforms::Phaser::Service)
|
||||
|
||||
allow(WarpEngine::Platforms::Phaser::Service).to receive(:new).and_return(mock_service)
|
||||
allow(mock_service).to receive(:update)
|
||||
|
||||
described_class.new.publish(input)
|
||||
|
||||
expect(mock_service).to have_received(:update).with("game", "1.0")
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,59 +0,0 @@
|
||||
require "rails_helper"
|
||||
|
||||
RSpec.describe WarpEngine::UpdateService do
|
||||
describe "#update" do
|
||||
it "raises ArgumentError for unsupported platform" do
|
||||
input = WarpEngine::UpdateInputDto.new(platform: "unknown", name: "game", version: "1.0")
|
||||
|
||||
expect { described_class.new.update(input) }.to raise_error(ArgumentError, /Unsupported platform/)
|
||||
end
|
||||
|
||||
it "routes to correct platform service" do
|
||||
input = WarpEngine::UpdateInputDto.new(platform: "tic80", name: "game", version: "1.0")
|
||||
mock_service = instance_double(WarpEngine::SoftwareUpdater::Tic80Service)
|
||||
|
||||
allow(WarpEngine::SoftwareUpdater::Tic80Service).to receive(:new).and_return(mock_service)
|
||||
allow(mock_service).to receive(:update)
|
||||
|
||||
described_class.new.update(input)
|
||||
|
||||
expect(mock_service).to have_received(:update).with("game", "1.0")
|
||||
end
|
||||
|
||||
it "routes godot platform to GodotService" do
|
||||
input = WarpEngine::UpdateInputDto.new(platform: "godot", name: "game", version: "1.0")
|
||||
mock_service = instance_double(WarpEngine::SoftwareUpdater::GodotService)
|
||||
|
||||
allow(WarpEngine::SoftwareUpdater::GodotService).to receive(:new).and_return(mock_service)
|
||||
allow(mock_service).to receive(:update)
|
||||
|
||||
described_class.new.update(input)
|
||||
|
||||
expect(mock_service).to have_received(:update).with("game", "1.0")
|
||||
end
|
||||
|
||||
it "routes bevy platform to BevyService" do
|
||||
input = WarpEngine::UpdateInputDto.new(platform: "bevy", name: "game", version: "1.0")
|
||||
mock_service = instance_double(WarpEngine::SoftwareUpdater::BevyService)
|
||||
|
||||
allow(WarpEngine::SoftwareUpdater::BevyService).to receive(:new).and_return(mock_service)
|
||||
allow(mock_service).to receive(:update)
|
||||
|
||||
described_class.new.update(input)
|
||||
|
||||
expect(mock_service).to have_received(:update).with("game", "1.0")
|
||||
end
|
||||
|
||||
it "routes phaser platform to PhaserService" do
|
||||
input = WarpEngine::UpdateInputDto.new(platform: "phaser", name: "game", version: "1.0")
|
||||
mock_service = instance_double(WarpEngine::SoftwareUpdater::PhaserService)
|
||||
|
||||
allow(WarpEngine::SoftwareUpdater::PhaserService).to receive(:new).and_return(mock_service)
|
||||
allow(mock_service).to receive(:update)
|
||||
|
||||
described_class.new.update(input)
|
||||
|
||||
expect(mock_service).to have_received(:update).with("game", "1.0")
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user