Skip to content

Commit

Permalink
Add ci_reporter_minitest to Gemfile and match h-c-f more closely
Browse files Browse the repository at this point in the history
  • Loading branch information
ianballou committed May 8, 2024
1 parent a2a12d3 commit b937997
Show file tree
Hide file tree
Showing 10 changed files with 45 additions and 43 deletions.
6 changes: 4 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ gemspec
self.instance_eval(Bundler.read_file(local_gemfile)) if File.exist?(local_gemfile)
end

gem 'gettext', '>= 3.1.3', '< 4.0.0'

group :test do
gem 'gettext', '>= 3.1.3', '< 4.0.0'
gem 'minitest', '4.7.4'
gem 'ci_reporter_minitest', :require => false
gem 'minitest', '~> 5.18'
gem 'minitest-spec-context', '~> 0.0.5'
gem 'mocha', '~> 2.0'
gem 'rake', '~> 10.0'
Expand Down
6 changes: 3 additions & 3 deletions test/functional/acs/create_test.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
require File.join(File.dirname(__FILE__), '../test_helper')

describe 'create content-credentials' do
describe 'create alternate content source' do
before do
@cmd = %w(alternate-content-source create)
end

let(:name) { 'pizza' }
let(:acs_name) { 'pizza' }
let(:url) { 'http://proxy.example.com' }
let(:acs_type) { 'custom' }
let(:acs_content) { 'yum' }
Expand All @@ -14,7 +14,7 @@
let(:subpaths) { ['test/repo1/'] }

it 'Creates an ACS' do
params = ["--name=#{name}", "--alternate-content-source-type=#{acs_type}",
params = ["--name=#{acs_name}", "--alternate-content-source-type=#{acs_type}",
"--base-url=#{url}", "--content-type=#{acs_content}", "--verify-ssl=#{verify_ssl}",
"--smart-proxy-ids=#{proxy_id}", "--subpaths=#{subpaths}"]

Expand Down
4 changes: 2 additions & 2 deletions test/functional/content_credentials/create_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
describe 'create content-credentials' do
before do
@cmd = %w(content-credentials create)
@base_params = ["--organization-id=#{org_id}", "--name=#{name}"]
@base_params = ["--organization-id=#{org_id}", "--name=#{cred_name}"]
end

let(:org_id) { 1 }
let(:name) { 'sslcert' }
let(:cred_name) { 'sslcert' }
let(:cert) { File.join(File.dirname(__FILE__), 'data', 'test_cert.json') }

it 'Creates a SSL Content Credential' do
Expand Down
14 changes: 7 additions & 7 deletions test/functional/content_export/complete/repository_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
let(:product_id) { '77' }
let(:repository_id) { '1001' }

let(:name) { 'repo' }
let(:repo_name) { 'repo' }

it "performs export with required options and async" do
params = [
Expand Down Expand Up @@ -111,7 +111,7 @@
end

it 'fails on missing product missing org' do
params = ["--product=lol", "--name=#{name}"]
params = ["--product=lol", "--name=#{repo_name}"]
result = run_cmd(@cmd + params)
expected_error = "At least one of options --organization-id,"\
" --organization, --organization-label is required"
Expand All @@ -122,13 +122,13 @@

it 'correctly resolves product_id and repository name' do
params = ["--product-id=#{product_id}",
"--name=#{name}",
"--name=#{repo_name}",
"--async"]
expects_repository(repository_id, default_repository_options)

cvv_expect = api_expects(:repositories, :index) do |p|
assert_equal p['product_id'].to_s, product_id.to_s
assert_equal p["name"], name
assert_equal p["name"], repo_name
end

cvv_expect.at_least_once.
Expand Down Expand Up @@ -203,11 +203,11 @@

it 'should accept product and get the right repository' do
params = ["--product-id=#{product_id}",
"--name=#{name}"]
expect_repository_search(product_id.to_i, name, repository_id).at_least_once
"--name=#{repo_name}"]
expect_repository_search(product_id.to_i, repo_name, repository_id).at_least_once
repo_search = api_expects(:repositories, :index, 'Find a repository') do |p|
assert_equal p["product_id"].to_s, product_id.to_s
assert_equal p["name"], name
assert_equal p["name"], repo_name
end
repo_search.returns(index_response([{'id' => repository_id}]))

Expand Down
12 changes: 6 additions & 6 deletions test/functional/content_export/incremental/repository_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
let(:product_id) { '77' }
let(:repository_id) { 100 }

let(:name) { 'great' }
let(:repo_name) { 'great' }

it "performs export with required options and async" do
params = [
Expand Down Expand Up @@ -120,13 +120,13 @@

it 'correctly resolves product_id and repository name' do
params = ["--product-id=#{product_id}",
"--name=#{name}",
"--name=#{repo_name}",
"--async"]
expects_repository(repository_id, default_repository_options)

cvv_expect = api_expects(:repositories, :index) do |p|
assert_equal p['product_id'].to_s, product_id.to_s
assert_equal p["name"], name
assert_equal p["name"], repo_name
end

cvv_expect.at_least_once.
Expand Down Expand Up @@ -157,7 +157,7 @@
end

it 'fails on missing product missing org' do
params = ["--product=lol", "--name=#{name}"]
params = ["--product=lol", "--name=#{repo_name}"]
result = run_cmd(@cmd + params)
expected_error = "At least one of options --organization-id,"\
" --organization, --organization-label is required"
Expand All @@ -168,13 +168,13 @@

it 'correctly resolves product_id and repository name' do
params = ["--product-id=#{product_id}",
"--name=#{name}",
"--name=#{repo_name}",
"--async"]
expects_repository(repository_id, default_repository_options)

cvv_expect = api_expects(:repositories, :index) do |p|
assert_equal p['product_id'].to_s, product_id.to_s
assert_equal p["name"], name
assert_equal p["name"], repo_name
end

cvv_expect.at_least_once.
Expand Down
6 changes: 3 additions & 3 deletions test/functional/content_view/create_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
describe 'content-view create' do
before do
@cmd = %w(content-view create)
@base_params = ["--organization-id=#{org_id}", "--name=#{name}"]
@base_params = ["--organization-id=#{org_id}", "--name=#{cv_name}"]
end
let(:error_heading) { "Could not create the content view" }
let(:name) { 'test-cv' }
let(:cv_name) { 'test-cv' }
let(:org_id) { 1 }
let(:repositories) do
[
Expand All @@ -22,7 +22,7 @@
params = %W(--repository-ids=#{ids.join(',')})

api_expects(:content_views, :create, 'Create content view') do |par|
par['name'] == name &&
par['name'] == cv_name &&
par['repository_ids'] == ids &&
par['organization_id'] == org_id
end
Expand Down
6 changes: 3 additions & 3 deletions test/functional/repository/create_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@
describe "create repository" do
let(:org_id) { 1 }
let(:product_id) { 2 }
let(:name) { "repo1" }
let(:repo_name) { "repo1" }
let(:content_type) { "yum" }

it 'with basic options' do
api_expects(:repositories, :create)
.with_params(
name: name,
name: repo_name,
product_id: product_id,
content_type: content_type)

command = %W(repository create --organization-id #{org_id} --product-id #{product_id}
--content-type #{content_type} --name #{name})
--content-type #{content_type} --name #{repo_name})

assert_equal(0, run_cmd(command).exit_code)
end
Expand Down
18 changes: 9 additions & 9 deletions test/functional/sync_plan/create_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

describe "create sync plan" do
let(:org_id) { 1 }
let(:name) { "sync_plan1" }
let(:sync_plan_name) { "sync_plan1" }
let(:hourly) { "hourly" }
let(:custom) { "custom cron" }
let(:cron) { "10 * * * *" }
Expand All @@ -11,31 +11,31 @@
it 'with organization ID,name,interval,date and enabled' do
api_expects(:sync_plans, :create, 'create a sync plan').
with_params('organization_id' => org_id,
'name' => name,
'name' => sync_plan_name,
'interval' => hourly,
'sync_date' => date,
'enabled' => true)
command = %W(sync-plan create --organization-id #{org_id} --name #{name}
command = %W(sync-plan create --organization-id #{org_id} --name #{sync_plan_name}
--interval #{hourly} --enabled 1 --sync-date #{date})
assert_equal(0, run_cmd(command).exit_code)
end

it 'with custom cron' do
api_expects(:sync_plans, :create, 'create a sync plan').
with_params('organization_id' => org_id,
'name' => name,
'name' => sync_plan_name,
'interval' => custom,
'cron_expression' => cron,
'sync_date' => date,
'enabled' => true)
# end
command = %W(sync-plan create --organization-id #{org_id} --name #{name} --interval #{custom}
--cron-expression #{cron} --enabled 1 --sync-date #{date})
command = %W(sync-plan create --organization-id #{org_id} --name #{sync_plan_name}
--interval #{custom} --cron-expression #{cron} --enabled 1 --sync-date #{date})
assert_equal(0, run_cmd(command).exit_code)
end

it 'fails without organization-id' do
command = %w(sync-plan create --name #{name}
command = %w(sync-plan create --name #{sync_plan_name}
--interval #{hourly} --enabled 1 --sync-date #{date})
refute_equal(0, run_cmd(command).exit_code)
end
Expand All @@ -47,13 +47,13 @@
end

it 'fails without interval' do
command = %w(sync-plan create --organization-id #{org_id} --name #{name}
command = %w(sync-plan create --organization-id #{org_id} --name #{sync_plan_name}
--enabled 1 --sync-date #{date})
refute_equal(0, run_cmd(command).exit_code)
end

it 'fails without enabled' do
command = %w(sync-plan create --organization-id #{org_id} --name #{name}
command = %w(sync-plan create --organization-id #{org_id} --name #{sync_plan_name}
--interval #{hourly} --sync-date #{date})
refute_equal(0, run_cmd(command).exit_code)
end
Expand Down
6 changes: 3 additions & 3 deletions test/functional/sync_plan/delete_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

let(:org_id) { 1 }
let(:id) { 1 }
let(:name) { "sync_plan1" }
let(:sync_plan_name) { "sync_plan1" }
let(:org_name) { "org1" }

it 'by organization ID and sync plan id' do
Expand All @@ -23,7 +23,7 @@
expect_sync_plan_search(1, 'sync_plan1', 1)
api_expects(:sync_plans, :destroy, 'delete a sync plan').
with_params('id' => id)
command = %W(sync-plan delete --organization-id #{org_id} --name #{name})
command = %W(sync-plan delete --organization-id #{org_id} --name #{sync_plan_name})
assert_equal(0, run_cmd(command).exit_code)
end

Expand All @@ -32,7 +32,7 @@
expect_sync_plan_search(1, 'sync_plan1', 1)
api_expects(:sync_plans, :destroy, 'delete a sync plan').
with_params('id' => id)
command = %W(sync-plan delete --organization #{org_name} --name #{name})
command = %W(sync-plan delete --organization #{org_name} --name #{sync_plan_name})
assert_equal(0, run_cmd(command).exit_code)
end

Expand Down
10 changes: 5 additions & 5 deletions test/functional/sync_plan/update_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

let(:org_id) { 1 }
let(:id) { 1 }
let(:name) { "sync_plan1" }
let(:sync_plan_name) { "sync_plan1" }
let(:org_name) { "org1" }
let(:desc) { "New Description" }

Expand All @@ -22,22 +22,22 @@
end

it 'with organization ID and sync plan name' do
expect_sync_plan_search(org_id, name, id)
expect_sync_plan_search(org_id, sync_plan_name, id)
api_expects(:sync_plans, :update, 'update a sync plan').
with_params('description' => desc,
'id' => id)
command = %W(sync-plan update --organization-id #{org_id} --name #{name}
command = %W(sync-plan update --organization-id #{org_id} --name #{sync_plan_name}
--description #{desc})
assert_equal(0, run_cmd(command).exit_code)
end

it 'with organization name and sync plan name' do
expect_organization_search(org_name, org_id)
expect_sync_plan_search(org_id, name, id)
expect_sync_plan_search(org_id, sync_plan_name, id)
api_expects(:sync_plans, :update, 'update a sync plan').
with_params('description' => desc,
'id' => id)
command = %W(sync-plan update --organization #{org_name} --name #{name}
command = %W(sync-plan update --organization #{org_name} --name #{sync_plan_name}
--description #{desc})
assert_equal(0, run_cmd(command).exit_code)
end
Expand Down

0 comments on commit b937997

Please sign in to comment.