Project

General

Profile

Download (2.73 KB) Statistics
| Branch: | Tag: | Revision:
87c40d2e Ohad Levy
require 'test_helper'

class ReportTest < ActiveSupport::TestCase
ff1cc6b1 Ohad Levy
def setup
91ad276d Greg Sutcliffe
User.current = User.admin
974075d7 Ohad Levy
@r=Report.import read_json_fixture("report-skipped.json")
ff1cc6b1 Ohad Levy
end

test "it should true on error? if there were errors" do
9b41cf08 Ohad Levy
@r.status={"applied" => 92, "restarted" => 300, "failed" => 4, "failed_restarts" => 12, "skipped" => 3, "pending" => 0}
ff1cc6b1 Ohad Levy
assert @r.error?
end

1c039da8 Ohad Levy
test "it should not be an error if there are only skips" do
9b41cf08 Ohad Levy
@r.status={"applied" => 92, "restarted" => 300, "failed" => 0, "failed_restarts" => 0, "skipped" => 3, "pending" => 0}
1c039da8 Ohad Levy
assert !@r.error?
end

446ad21e Lucas Tolchinsky
test "it should false on error? if there were no errors" do
9b41cf08 Ohad Levy
@r.status={"applied" => 92, "restarted" => 300, "failed" => 0, "failed_restarts" => 0, "skipped" => 0, "pending" => 0}
1c039da8 Ohad Levy
assert !@r.error?
87c40d2e Ohad Levy
end
c5d4bcbe Ohad Levy
446ad21e Lucas Tolchinsky
test "with named scope should return our report with applied resources" do
9b41cf08 Ohad Levy
@r.status={"applied" => 15, "restarted" => 0, "failed" => 0, "failed_restarts" => 0, "skipped" => 0, "pending" => 0}
ff1cc6b1 Ohad Levy
@r.save
assert Report.with("applied",14).include?(@r)
67799065 Ohad Levy
assert !Report.with("applied", 15).include?(@r)
446ad21e Lucas Tolchinsky
end
ff1cc6b1 Ohad Levy
446ad21e Lucas Tolchinsky
test "with named scope should return our report with restarted resources" do
9b41cf08 Ohad Levy
@r.status={"applied" => 0, "restarted" => 5, "failed" => 0, "failed_restarts" => 0, "skipped" => 0, "pending" => 0}
ff1cc6b1 Ohad Levy
@r.save
assert Report.with("restarted").include?(@r)
446ad21e Lucas Tolchinsky
end
ff1cc6b1 Ohad Levy
446ad21e Lucas Tolchinsky
test "with named scope should return our report with failed resources" do
9b41cf08 Ohad Levy
@r.status={"applied" => 0, "restarted" => 0, "failed" => 9, "failed_restarts" => 0, "skipped" => 0, "pending" => 0}
ff1cc6b1 Ohad Levy
@r.save
assert Report.with("failed").include?(@r)
446ad21e Lucas Tolchinsky
end
ff1cc6b1 Ohad Levy
446ad21e Lucas Tolchinsky
test "with named scope should return our report with failed_restarts resources" do
9b41cf08 Ohad Levy
@r.status={"applied" => 0, "restarted" => 0, "failed" => 0, "failed_restarts" => 91, "skipped" => 0, "pending" => 0}
ff1cc6b1 Ohad Levy
@r.save
assert Report.with("failed_restarts").include?(@r)
446ad21e Lucas Tolchinsky
end
ff1cc6b1 Ohad Levy
446ad21e Lucas Tolchinsky
test "with named scope should return our report with skipped resources" do
9b41cf08 Ohad Levy
@r.status={"applied" => 0, "restarted" => 0, "failed" => 0, "failed_restarts" => 0, "skipped" => 8, "pending" => 0}
ff1cc6b1 Ohad Levy
@r.save
assert Report.with("skipped").include?(@r)
446ad21e Lucas Tolchinsky
end
ff1cc6b1 Ohad Levy
446ad21e Lucas Tolchinsky
test "with named scope should return our report with skipped resources when other bits are also used" do
9b41cf08 Ohad Levy
@r.status={"applied" => 0, "restarted" => 0, "failed" => 9, "failed_restarts" => 4, "skipped" => 8, "pending" => 3}
ff1cc6b1 Ohad Levy
@r.save
assert Report.with("skipped").include?(@r)
446ad21e Lucas Tolchinsky
end
9fd7478e Paul Kelly
9b41cf08 Ohad Levy
test "with named scope should return our report with pending resources when other bits are also used" do
@r.status={"applied" => 0, "restarted" => 0, "failed" => 9, "failed_restarts" => 4, "skipped" => 8, "pending" => 3}
@r.save
assert Report.with("pending").include?(@r)
end

87c40d2e Ohad Levy
end