mirror of
https://github.com/ubicloud/ubicloud.git
synced 2025-11-28 16:40:27 +08:00
Fixes and improvements to previous commit: * Add delete_all_cache_entries to LOGGED_ACTIONS. * Change optional initiated_at assemble argument from positional to keyword. * Don't use repository_id as the id of the created strand. * Remove unnecessary start label in prog. * Only delete cache entries before initiated at. * Add next_entry method to prog for easier mocking. * Update flash notices used in route. * Only mock when necessary in the specs. * Simplify web and cli specs. * Only use a transaction in the route if there are cache entries.
26 lines
1.8 KiB
Ruby
26 lines
1.8 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
require_relative "../spec_helper"
|
|
|
|
RSpec.describe Clover, "cli gh remove-all-cache-entries" do
|
|
it "removes all cache entries" do
|
|
expect(Config).to receive(:github_app_name).and_return("test-app").at_least(:once)
|
|
gi = GithubInstallation.create_with_id("6e3ae4a8-5474-8a01-b485-3b02ac649c5f", project_id: @project.id, installation_id: 12345678, name: "test-installation-name", type: "user")
|
|
gp = GithubRepository.create_with_id("a58006b6-0879-8616-936a-62234e244f2f", installation_id: gi.id, name: "test-installation-name/test-repository-name")
|
|
GithubCacheEntry.create_with_id("967f7e02-68f8-8a0e-9917-fd13d5f33501", repository_id: gp.id, key: "test-key-1", version: "test-version", scope: "test-scope", size: 10987654321, created_by: gp.id, committed_at: Time.now)
|
|
|
|
expect(cli(%w[gh test-installation-name/test-repository-name remove-all-cache-entries])).to eq "All cache entries, if they exist, are now scheduled for destruction\n"
|
|
st = Strand.first(prog: "Github::DeleteCacheEntries")
|
|
expect(st.label).to eq "delete_entries"
|
|
end
|
|
|
|
it "handles case where there are no cache entries" do
|
|
expect(Config).to receive(:github_app_name).and_return("test-app").at_least(:once)
|
|
gi = GithubInstallation.create_with_id("6e3ae4a8-5474-8a01-b485-3b02ac649c5f", project_id: @project.id, installation_id: 12345678, name: "test-installation-name", type: "user")
|
|
GithubRepository.create_with_id("a58006b6-0879-8616-936a-62234e244f2f", installation_id: gi.id, name: "test-installation-name/test-repository-name")
|
|
|
|
expect(cli(%w[gh test-installation-name/test-repository-name remove-all-cache-entries])).to eq "All cache entries, if they exist, are now scheduled for destruction\n"
|
|
st = Strand.first(prog: "Github::DeleteCacheEntries")
|
|
expect(st).to be_nil
|
|
end
|
|
end
|