Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mithereal committed Jan 1, 2024
1 parent b46bd45 commit 5891279
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 28 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ jobs: # basic units of work in a run
docker: # run the steps with Docker
- image: cimg/elixir:1.15.5-erlang-26.0.2 # ...with this image as the primary container; this is where all `steps` will run
environment: # environment variables for primary container
MIX_ENV: test
MIX_ENV: circleci

working_directory: ~/app # directory where steps will run

Expand Down
59 changes: 33 additions & 26 deletions lib/speedtest.ex
Original file line number Diff line number Diff line change
Expand Up @@ -248,47 +248,54 @@ defmodule Speedtest do

selected_server = choose_best_server(closest_servers)

{_, _, ping} = selected_server.ping
{status, _, response} = selected_server.ping

ping = to_string(ping)
reply =
case status do
:ok ->
ping = to_string(response)

elapsed_time = ping <> " ms"
elapsed_time = ping <> " ms"

Logger.info(
"Hosted by " <>
selected_server.sponsor <>
" (" <>
selected_server.name <>
") " <>
"[" <>
to_string(Float.round(selected_server.distance / 1000)) <> " km]: " <> elapsed_time
)
Logger.info(
"Hosted by " <>
selected_server.sponsor <>
" (" <>
selected_server.name <>
") " <>
"[" <>
to_string(Float.round(selected_server.distance / 1000)) <> " km]: " <> elapsed_time
)

speedtest = %{result | selected_server: selected_server}
speedtest = %{result | selected_server: selected_server}

{_, download_reply} = download(speedtest)
{_, download_reply} = download(speedtest)

{_, upload_reply} = upload(speedtest)
{_, upload_reply} = upload(speedtest)

replys = {upload_reply, download_reply}
replys = {upload_reply, download_reply}

{_, reply} = Result.create(speedtest, replys)
{_, reply} = Result.create(speedtest, replys)

speed = to_string(reply.result.download) <> " Mbit/s"
Logger.info("Download: " <> speed)
speed = to_string(reply.result.download) <> " Mbit/s"
Logger.info("Download: " <> speed)

speed = to_string(reply.result.upload) <> " Mbit/s"
Logger.info("Upload: " <> speed)
speed = to_string(reply.result.upload) <> " Mbit/s"
Logger.info("Upload: " <> speed)

config = reply.config
config = reply.config

client = reply.result.client
client = reply.result.client

config = %{config | client: client}
config = %{config | client: client}

reply = %{reply | config: config}
%{reply | config: config}

{:ok, reply}
_ ->
response
end

{status, reply}
end

@doc """
Expand Down
9 changes: 8 additions & 1 deletion test/speedtest_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ defmodule SpeedtestTest do

test "Run the Speedtest" do
{status, _} = Speedtest.run()
assert status == :ok

case Mix.env() do
:test ->
assert status == :ok

:circleci ->
assert status == :error
end
end
end

0 comments on commit 5891279

Please sign in to comment.