require_relative '../test_config' require 'fileutils' require 'base64' require 'helix_versioning_engine' describe 'HelixVersioningEngine changes' do include Rack::Test::Methods def app HELIX_WEB_SERVICES_APP end context 'GET /helix_versioning_engine/v78/changes' do it 'should list change 1' do authorize 'jdoe', ticket_for_jdoe get('/helix_versioning_engine/v78/changes') expect(last_response.status).to eq(200) changes = JSON.parse(last_response.body) expect(changes.map { |c| c['change'] }).to include('1') end it 'can limit the test results to 1 with the max parameter' do authorize 'jdoe', ticket_for_jdoe get('/helix_versioning_engine/v78/changes?max=1') expect(last_response.status).to eq(200) changes = JSON.parse(last_response.body) expect(changes.length).to eq(1) end it 'can limit the change results by user' do authorize 'jdoe', ticket_for_jdoe get('/helix_versioning_engine/v78/changes?user=super') expect(last_response.status).to eq(200) changes = JSON.parse(last_response.body) expect(changes.map { |c| c['user'] }).to satisfy { |x| x.all? { |y| y == 'super'} } end it 'can limit the change results by status' do authorize 'jdoe', ticket_for_jdoe get('/helix_versioning_engine/v78/changes?status=submitted') expect(last_response.status).to eq(200) changes = JSON.parse(last_response.body) expect(changes.map { |c| c['status'] }).to satisfy { |x| x.all? { |y| y == 'submitted'} } end it 'can limit the change results by a files query' do authorize 'jdoe', ticket_for_jdoe get('/helix_versioning_engine/v78/changes?files=//depot/dev/Experimental/README') expect(last_response.status).to eq(200) changes = JSON.parse(last_response.body) expect(changes.map { |c| c['change'] }).to include('1') end end context 'POST /helix_versioning_engine/v78/changes' do # This test is really only valid after an immediate reset of p4d. it 'can branch files' do rand_str = (0...8).map { (65 + rand(26)).chr }.join request_body = { 'Files' => [ { 'DepotFile' => "//depot/test-#{rand_str}/Experimental/...", 'FromDepotFile' => '//depot/dev/Experimental/...', 'Action' => 'branch' } ] } authorize 'jdoe', ticket_for_jdoe post('/helix_versioning_engine/v78/changes', request_body) expect(last_response.status).to eq(200) get("/helix_versioning_engine/v78/files/depot/test-#{rand_str}/Experimental") expect(last_response.status).to eq(200) files = JSON.parse(last_response.body) expect(files.map {|f| f['depotFile']}).to include("//depot/test-#{rand_str}/Experimental/README") end it 'can add files' do rand_str = (0...8).map { (65 + rand(26)).chr }.join request_body = { 'Description' => 'Upload two experimental files', 'Files' => [ { 'DepotFile' => "//depot/dev/Experimental/teapot1-#{rand_str}.txt", 'Action' => 'upload', 'Content' => Base64.encode64("I'm a little teapot") }, { 'DepotFile' => "//depot/dev/Experimental/teapot2-#{rand_str}.txt", 'Action' => 'upload', 'Content' => Base64.encode64('Short and stout!') } ] } authorize 'jdoe', ticket_for_jdoe post('/helix_versioning_engine/v78/changes', request_body) expect(last_response.status).to eq(200) get('/helix_versioning_engine/v78/files/depot/dev/Experimental') expect(last_response.status).to eq(200) files = JSON.parse(last_response.body) expect(files.map {|f| f['depotFile']}).to include("//depot/dev/Experimental/teapot1-#{rand_str}.txt") expect(files.map {|f| f['depotFile']}).to include("//depot/dev/Experimental/teapot2-#{rand_str}.txt") end end context 'GET /helix_versioning_engine/v78/changes/[change]' do it 'can describe file lists in submitted changes' do authorize 'jdoe', ticket_for_jdoe get('/helix_versioning_engine/v78/changes/1') expect(last_response.status).to eq(200) change = JSON.parse(last_response.body).first expect(change['depotFile']).to include('//depot/dev/Experimental/README') expect(change['depotFile']).to include('//depot/main/My Project/README') end end context 'POST /helix_versioning_engine/v78/changes/[change]' do it 'can submit a changelist with shelved changes on a normal client' do rand_str = (0...8).map { (65 + rand(26)).chr }.join relative_path = "depot/shelved_stuff/#{rand_str}" temp_client_as_jdoe do |p4, p4_root| path = File.absolute_path("#{p4_root}/#{relative_path}") unless Dir.exist?(File.dirname(path)) FileUtils.mkdir_p(File.dirname(path)) end IO.write(path, "I'm a little teapot") change_spec = p4.fetch_change change_spec._description = "Testing shelving for #{rand_str}" results = p4.save_change(change_spec) change_num = /^Change (\d+) created.$/.match(results.first)[1] #puts "change_num: #{change_num}" results = p4.run_add('-c', change_num, path) #puts "add: #{results}" results = p4.run_shelve('-c', change_num) #puts "shelve: #{results}" results = p4.run_revert('-c', change_num, path) #puts "revert: #{results}" authorize 'jdoe', ticket_for_jdoe post("/helix_versioning_engine/v78/changes/#{change_num}") end expect(last_response.status).to eq(200) get("/helix_versioning_engine/v78/files/#{relative_path}") expect(last_response.status).to eq(200) file = JSON.parse(last_response.body) expect(file['depotFile']).to eq("//#{relative_path}") end it 'can submit a changelist with shelved changes on a normal client' do rand_str = (0...8).map { (65 + rand(26)).chr }.join relative_path = "shelved_stuff/#{rand_str}" stream = nil temp_stream_client_as_jdoe do |p4, p4_root, s| stream = s path = File.absolute_path("#{p4_root}/#{relative_path}") unless Dir.exist?(File.dirname(path)) FileUtils.mkdir_p(File.dirname(path)) end IO.write(path, "I'm a little teapot") change_spec = p4.fetch_change change_spec._description = "Testing shelving for #{rand_str}" results = p4.save_change(change_spec) change_num = /^Change (\d+) created.$/.match(results.first)[1] #puts "change_num: #{change_num}" results = p4.run_add('-c', change_num, path) #puts "add: #{results}" results = p4.run_shelve('-c', change_num) #puts "shelve: #{results}" results = p4.run_revert('-c', change_num, path) #puts "revert: #{results}" authorize 'jdoe', ticket_for_jdoe post("/helix_versioning_engine/v78/changes/#{change_num}") end expect(last_response.status).to eq(200) get("/helix_versioning_engine/v78/files/#{stream}/#{relative_path}") expect(last_response.status).to eq(200) file = JSON.parse(last_response.body) expect(file['depotFile']).to eq("#{stream}/#{relative_path}") 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_versioning_engine/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_versioning_engine/changes_spec.rb | |||||
#5 | 15240 | tjuricek |
Set api level via request path on all Helix Versioning Engine methods. This will allow migration of applications to different P4D versions. Our internal methods (like project API) should attempt to handle backward compatibility similarly. P4WEBAPI-118 |
||
#4 | 15147 | tjuricek |
Enable submissions by files on stream clients This obeys our earlier rules: notably the local client must not have any local files open for edit. |
||
#3 | 15132 | tjuricek | Provde a basic submit -e mechanism on classic perforce workspaces. | ||
#2 | 15112 | tjuricek | Fix references to Base64 methods | ||
#1 | 15110 | tjuricek | Revise changes methods for new p4 connection handling, add server specs, remove model references in client, and update asciidoc documentation. |