Skip to content

Commit

Permalink
Merge pull request #226 from mamantoha/windows-ci
Browse files Browse the repository at this point in the history
add windows to ci
  • Loading branch information
mamantoha committed Jul 26, 2024
2 parents 05cea39 + 3173eba commit 5298bad
Show file tree
Hide file tree
Showing 14 changed files with 202 additions and 197 deletions.
3 changes: 3 additions & 0 deletions .ameba.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@ Globs:
- "**/*.cr"
- "!samples"
- "!lib"

Naming/BlockParameterName:
Enabled: false
1 change: 1 addition & 0 deletions .github/workflows/crystal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ jobs:
- {os: ubuntu-latest, crystal: nightly}
- {os: macos-latest}
- {os: macos-14}
- {os: windows-latest}
runs-on: ${{ matrix.os }}
steps:
- name: Install Crystal
Expand Down
6 changes: 0 additions & 6 deletions shard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,6 @@ dependencies:
version: ">= 0.10.2"

development_dependencies:
kemal:
github: kemalcr/kemal
version: ~> 1.0.0
branch: master
kemal-basic-auth:
github: kemalcr/kemal-basic-auth
vcr:
github: spoved/vcr.cr
branch: master
Expand Down
2 changes: 1 addition & 1 deletion spec/integration/exception_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ describe Crest do
ex.response
end

response.body.should eq("500 error")
response.body.chomp.should eq("500 Internal Server Error")
end

it "404 with Resource" do
Expand Down
2 changes: 1 addition & 1 deletion spec/integration/proxy_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe Crest do
response = request.execute

(response.status_code).should eq(200)
(response.body).should eq("{}\n")
(response.body.chomp).should eq("{}")
end
ensure
wants_close.send(nil)
Expand Down
4 changes: 2 additions & 2 deletions spec/integration/redirection_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ describe Crest::Redirector do

(response.url).should eq("#{TEST_SERVER_URL}/redirect/1")
(response.status_code).should eq(302)
(response.body).should eq("Redirecting to /")
(response.body).should eq("")
end

it "should not raise exception in the block when handle_errors is false" do
Expand All @@ -86,7 +86,7 @@ describe Crest::Redirector do
body = response.body_io.gets_to_end
end

body.should eq("Redirecting to /")
body.should eq("")
status_code.should eq(302)
end
end
Expand Down
18 changes: 9 additions & 9 deletions spec/integration/request_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -283,21 +283,21 @@ describe Crest::Request do
end

it "upload IO::Memory directly" do
file_content = "id,name\n1,test"
file_content = "{\"foo\":\"bar\"}"
file = IO::Memory.new(file_content)
response = Crest::Request.post("#{TEST_SERVER_URL}/upload", form: file, headers: {"Content-Type" => "text/csv"})
response = Crest::Request.post("#{TEST_SERVER_URL}/upload", form: file, headers: {"Content-Type" => "application/json"})
body = response.body
(body).should match(/Upload OK/)
file_path = body.gsub("Upload OK - ", "")
(file_path.ends_with?(".csv")).should be_true
(file_path.ends_with?(".json")).should be_true
(File.read(file_path)).should eq(file_content)
end

it "upload IO::Memory as form hash value" do
file_content = "id,name\n1,test"
file_content = "{\"foo\":\"bar\"}"
file = IO::Memory.new(file_content)
request = Crest::Request.new(:POST, "#{TEST_SERVER_URL}/upload", form: {"file.csv" => file})
(request.form_data.to_s).should contain("Content-Type: text/csv")
request = Crest::Request.new(:POST, "#{TEST_SERVER_URL}/upload", form: {"file.json" => file})
(request.form_data.to_s).should contain("Content-Type: application/json")
response = request.execute
body = response.body
(body).should match(/Upload OK/)
Expand All @@ -306,13 +306,13 @@ describe Crest::Request do
end

it "upload Bytes directly" do
file_content = "id,name\n1,test"
file_content = "{\"foo\":\"bar\"}"
file = file_content.to_slice
response = Crest::Request.post("#{TEST_SERVER_URL}/upload", form: file, headers: {"Content-Type" => "text/csv"})
response = Crest::Request.post("#{TEST_SERVER_URL}/upload", form: file, headers: {"Content-Type" => "application/json"})
body = response.body
(body).should match(/Upload OK/)
file_path = body.gsub("Upload OK - ", "")
(file_path.ends_with?(".csv")).should be_true
(file_path.ends_with?(".json")).should be_true
(File.read(file_path)).should eq(file_content)
end

Expand Down
14 changes: 1 addition & 13 deletions spec/spec_helper.cr
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,10 @@ require "vcr"
require "../src/crest"
require "./support/server"

TEST_SERVER_HOST = "0.0.0.0"
TEST_SERVER_HOST = "127.0.0.1"
TEST_SERVER_PORT = 4567
TEST_SERVER_URL = "http://#{TEST_SERVER_HOST}:#{TEST_SERVER_PORT}"

kemal_config = Kemal.config
kemal_config.env = "development"
kemal_config.logging = false

spawn do
Kemal.run(port: TEST_SERVER_PORT)
end

until Kemal.config.running
sleep 1.millisecond
end

def with_proxy_server(host = "127.0.0.1", port = 8080, &)
wants_close = Channel(Nil).new
server = HTTP::Proxy::Server.new
Expand Down
Loading

0 comments on commit 5298bad

Please sign in to comment.