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 | |
---|---|---|---|---|---|
#12 | 17271 | tjuricek | Remove deprecated Ruby implementation. | ||
#11 | 16167 | tjuricek |
Use the '-x' flag on a specific client to obtain a "lock" before submitting files. Also using the lock on typically generated temporary clients just in case. |
||
#10 | 16106 | tjuricek |
Revise the URLs for Helix Sync client workspaces. Added *stubs* for deleting the clients for a user, implementations will follow. |
||
#9 | 16103 | tjuricek | Revision of helix sync 'changelist' methods. | ||
#8 | 16102 | tjuricek | Rename GET /helix-sync/v1/changes/[project] -> GET /helix-sync/v1/[project]/last-change | ||
#7 | 16097 | tjuricek |
Remove POST /helix-sync/v1/changes/[project] This will be handled by the Helix Sync client. |
||
#6 | 16096 | tjuricek | Rename '/helix_sync' URLs to '/helix-sync' | ||
#5 | 16092 | tjuricek |
The 'fetch latest' changelist now depends upon the shelve client existing for the request. This may not be an obvious dependency. |
||
#4 | 16091 | tjuricek |
Alter Helix Sync client options and the 'latest pending changelist' query (via Alan Teague) The 'fetch pending changelist' method now requires that the changelist have the 'shelved' status. This is generally appropriate, but requires a bit more client usage, to make simple unit tests... kind of annoying actually. Since this function is used by some of the other Helix Sync workflow tests, I've just removed the smaller tests. |
||
#3 | 15992 | tjuricek |
Add default parameter option to getting the pending changelist for a Helix Sync project. This allows clients that treat HTTP errors as networking errors to not receive a 404 if the changelist doesn't exist. |
||
#2 | 15757 | tjuricek |
Add resolve implementation for submitting from shelves for Helix Sync Includes additional concepts for creating a "helix sync shelf client" vs a "helix sync device client". It's expected that there's basically one shelf client per user per project. The "device" client is an additional client per user per project per machine. The HWS services will submit via the "shelf client". The resolve implementation remains untested at the moment in order to get the client changes in the hands of Helix Sync developers. |
||
#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. |