require_relative '../test_config' require 'hws_settings' require 'helix_sync' require 'base64' require 'hws_strings' describe 'HelixSync changes' do include Rack::Test::Methods def app HELIX_WEB_SERVICES_APP end my_project_id = HWSStrings.component_encode('My Project') after(:each) do HWSSettings.settings_handle.HVE_PROJECTS_PATH = nil end pending_change = nil context 'GET /helix_sync/v1/changes/:project_id/pending' do context 'HVE projects' do it 'can fetch the latest change for the project' do HWSSettings.settings_handle.HVE_PROJECTS_PATH = '//depot/main' authorize 'jdoe', ticket_for_jdoe get("/helix_sync/v1/changes/#{my_project_id}") expect(last_response.status).to eq(200) info = JSON.parse(last_response.body) expect(info['change'].to_i).to be > 1 end end end context 'POST /helix_sync/v1/changes/:project_id' do context 'HVE projects' do it 'can create a pending changelist for the project' do HWSSettings.settings_handle.HVE_PROJECTS_PATH = '//depot/main' authorize 'jdoe', ticket_for_jdoe post("/helix_sync/v1/changes/#{my_project_id}") expect(last_response.status).to eq(200) info = JSON.parse(last_response.body) expect(info['change']).to_not be_nil end end end context 'GET /helix_sync/v1/changes/:project_id/pending' do context 'HVE projects' do it 'can fetches the pending changelist for a project' do HWSSettings.settings_handle.HVE_PROJECTS_PATH = '//depot/main' authorize 'jdoe', ticket_for_jdoe get("/helix_sync/v1/changes/#{my_project_id}/pending") expect(last_response.status).to eq(200) info = JSON.parse(last_response.body) expect(info['change']).to_not be_nil pending_change = info['change'] end end end context 'POST /helix_sync/v1/changes/:project_id/pending' do context 'HVE projects' do it 'can submit the pending changelist for a project with shelved files' do HWSSettings.settings_handle.HVE_PROJECTS_PATH = '//depot/main' # Obtain a client pointing to a temporary directory client_info = { project: my_project_id, device: 'test_device', root: Dir.mktmpdir('test_helix_sync') } authorize 'jdoe', ticket_for_jdoe post('/helix_sync/v1/clients', client_info) expect(last_response.status).to eq(200) client_name = JSON.parse(last_response.body)['client'] # Update our pending changelist to use our project client p4_as_jdoe do |p4| p4.client = client_name change_spec = p4.fetch_change(pending_change) change_spec._client = client_name p4.save_change(change_spec) end # Add and shelve a new test file rand_str = (0...8).map { (65 + rand(26)).chr }.join path = File.absolute_path("#{client_info[:root]}/#{rand_str}") unless Dir.exist?(File.dirname(path)) FileUtils.mkdir_p(File.dirname(path)) end IO.write(path, "I'm a little teapot") p4_as_jdoe do |p4| p4.client = client_name results = p4.run_add('-c', pending_change, path) #puts "add: #{results}" results = p4.run_shelve('-c', pending_change) #puts "shelve: #{results}" results = p4.run_revert('-c', pending_change, path) #puts "revert: #{results}" end # Test our submit authorize 'jdoe', ticket_for_jdoe post("/helix_sync/v1/changes/#{my_project_id}/pending") expect(last_response.status).to eq(200) end end end end
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 15741 | ptomiak | Branch HWS for my use. | ||
//guest/perforce_software/helix-web-services/main/source/helix_web_services/spec/helix_sync/changes_spec.rb | |||||
#1 | 15622 | tjuricek |
Move source code to 'source/' subdirectory of branch. build/ will remain where it is. |
||
//guest/perforce_software/helix-web-services/main/helix_web_services/spec/helix_sync/changes_spec.rb | |||||
#6 | 15542 | tjuricek |
Add spaces to our basic 'component encode' mechanism, and use it for HVE project IDs. In general, this will make the HVE IDs a bit more readable. |
||
#5 | 15517 | tjuricek | Do not require changelist ID for submitting Helix Sync pending changelists. | ||
#4 | 15499 | tjuricek | Naive implementation of helix sync project submit for "helix versioning engine projects". | ||
#3 | 15497 | tjuricek | Add support to fetch the latest change of a project. | ||
#2 | 15496 | tjuricek |
Revise GET /helix_sync/v1/changes/[project] to /helix_sync/v1/changes/[project]/pending The base method is really intended for the latest changelist number. Meh. |
||
#1 | 15487 | tjuricek | Add basic ability to create pending changelists for helix sync projects. |