Skip to content

Commit

Permalink
Merge pull request #13 from fastruby/fixes-1
Browse files Browse the repository at this point in the history
Start accepting data for benchmark environment
  • Loading branch information
arielj authored Oct 12, 2023
2 parents d4f4223 + 7636676 commit fe225fd
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 9 deletions.
5 changes: 4 additions & 1 deletion app/controllers/reports_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ def create
end
end

rep = Report.create report: JSON.generate(ary)
rep = Report.create report: JSON.generate(ary),
ruby: input["ruby"],
os: input["os"],
arch: input["arch"]

options = input["options"] || {}

Expand Down
7 changes: 7 additions & 0 deletions db/migrate/20231006184214_add_attributes_to_reports.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class AddAttributesToReports < ActiveRecord::Migration[7.0]
def change
add_column :reports, :ruby, :string
add_column :reports, :os, :string
add_column :reports, :arch, :string
end
end
14 changes: 8 additions & 6 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,26 @@
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# This file is the source Rails uses to define your schema when running `rails
# db:schema:load`. When creating a new database, `rails db:schema:load` tends to
# This file is the source Rails uses to define your schema when running `bin/rails
# db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to
# be faster and is potentially less error prone than running all of your
# migrations from scratch. Old migrations may fail to apply correctly if those
# migrations use external dependencies or application code.
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 2016_04_13_035657) do

ActiveRecord::Schema[7.0].define(version: 2023_10_06_184214) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"

create_table "reports", id: :serial, force: :cascade do |t|
t.text "report"
t.boolean "compare"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.datetime "created_at", precision: nil, null: false
t.datetime "updated_at", precision: nil, null: false
t.string "ruby"
t.string "os"
t.string "arch"
end

end
33 changes: 31 additions & 2 deletions test/controllers/reports_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class ReportsControllerTest < ActionController::TestCase
}]
}
DATA

post :create, body: data

assert_equal "400", @response.code
Expand All @@ -79,10 +79,39 @@ class ReportsControllerTest < ActionController::TestCase
}]
}
DATA

post :create, body: data

assert_equal "400", @response.code
end

test "environment variables are sent, processed, and saved" do
data = {
"ruby" => "3.2.1",
"os" => "Linux",
"arch" => "x86_64",
"entries" => [
{
"name" => "test",
"ips" => 10.1,
"central_tendency" => 10.1,
"error" => 23666,
"stddev" => 0.3,
"microseconds" => 3322,
"iterations" => 221,
"cycles" => 16
}
]
}

post :create, body: data.to_json

rep = JSON.parse @response.body

report = Report.find_from_short_id rep["id"]

assert_equal "3.2.1", report.ruby
assert_equal "Linux", report.os
assert_equal "x86_64", report.arch
end
end

0 comments on commit fe225fd

Please sign in to comment.