Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
jreidinger committed Jun 12, 2018
1 parent e3827eb commit ab6be3d
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions test/lib/clients/repositories_test.rb
Expand Up @@ -105,4 +105,46 @@
end
end
end

describe "#SortReposByPriority" do
it "returns nil if param is nil" do
expect(client.SortReposByPriority(nil)).to eq nil
end

it "returns input sort by priorities" do
repos = [
{ "priority" => 10, "name" => "repo1" },
{ "priority" => 30, "name" => "repo2" },
{ "priority" => 20, "name" => "repo3" }
]

expected_output = [
{ "priority" => 10, "name" => "repo1" },
{ "priority" => 20, "name" => "repo3" },
{ "priority" => 30, "name" => "repo2" }
]

expect(client.SortReposByPriority(repos)).to eq expected_output
end

it "sorts by name when priority is same" do
repos = [
{ "priority" => 10, "name" => "repo1" },
{ "priority" => 30, "name" => "repo2" },
{ "priority" => 20, "name" => "repo4" },
{ "priority" => 20, "name" => "repo3" },
{ "priority" => 20, "name" => "repo5" }
]

expected_output = [
{ "priority" => 10, "name" => "repo1" },
{ "priority" => 20, "name" => "repo3" },
{ "priority" => 20, "name" => "repo4" },
{ "priority" => 20, "name" => "repo5" },
{ "priority" => 30, "name" => "repo2" }
]

expect(client.SortReposByPriority(repos)).to eq expected_output
end
end
end

0 comments on commit ab6be3d

Please sign in to comment.