p4_web_api_client 2014.2.0.pre2 → 2014.2.0.pre4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/p4_web_api_client/client.rb +5 -5
- data/lib/p4_web_api_client/client/branches.rb +1 -1
- data/lib/p4_web_api_client/client/changes.rb +15 -0
- data/lib/p4_web_api_client/client/clients.rb +1 -1
- data/lib/p4_web_api_client/client/{run.rb → commands.rb} +15 -6
- data/lib/p4_web_api_client/client/depots.rb +1 -1
- data/lib/p4_web_api_client/client/files.rb +55 -50
- data/lib/p4_web_api_client/client/groups.rb +1 -1
- data/lib/p4_web_api_client/client/jobs.rb +1 -1
- data/lib/p4_web_api_client/client/labels.rb +1 -1
- data/lib/p4_web_api_client/client/servers.rb +2 -1
- data/lib/p4_web_api_client/client/streams.rb +1 -1
- data/lib/p4_web_api_client/client/users.rb +1 -1
- data/lib/p4_web_api_client/connection.rb +7 -7
- data/lib/p4_web_api_client/models/change.rb +74 -1
- data/lib/p4_web_api_client/models/file.rb +13 -0
- data/lib/p4_web_api_client/version.rb +1 -1
- data/spec/branches_spec.rb +0 -4
- data/spec/change_spec.rb +54 -1
- data/spec/clients_spec.rb +0 -4
- data/spec/depots_spec.rb +0 -4
- data/spec/{run_spec.rb → exec_spec.rb} +2 -3
- data/spec/{run_input_spec.rb → execi_spec.rb} +2 -3
- data/spec/files_spec.rb +40 -39
- data/spec/groups_spec.rb +0 -4
- data/spec/jobs_spec.rb +0 -4
- data/spec/labels_spec.rb +0 -4
- data/spec/lib/test_connections.rb +2 -2
- data/spec/protections_spec.rb +0 -2
- data/spec/servers_spec.rb +0 -4
- data/spec/streams_spec.rb +0 -4
- data/spec/triggers_spec.rb +10 -1
- data/spec/users_spec.rb +0 -5
- metadata +9 -10
- data/lib/p4_web_api_client/models/upload_file.rb +0 -42
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 60acdd9017591dd155ba2281a6988ccf8361883c
|
4
|
+
data.tar.gz: f80d7306763682389c7f2cafbcaf1ba7f6ff14ae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: addb3741478456b6d31c3b4781adc19aff205586b871c9482097a024ce8e4d54d2831904fd0d0d61697f18d0f83b12e9ab68307e2cadcc5de513a1654921717a
|
7
|
+
data.tar.gz: 6c7e932d2b9faab856624505fc5a478f89860fb516464343374dff3c39c0638adf606b04f3e9b833dae815081530461bdd83e8f4cf85044cb971aeeeb9d2600f
|
@@ -1,6 +1,7 @@
|
|
1
1
|
|
2
2
|
require 'json'
|
3
3
|
require 'open-uri'
|
4
|
+
require 'p4_web_api_client/connection'
|
4
5
|
require 'p4_web_api_client/version'
|
5
6
|
require 'p4_web_api_client/errors'
|
6
7
|
require 'p4_web_api_client/models'
|
@@ -17,8 +18,6 @@ module P4WebApiClient
|
|
17
18
|
# i.e., editing models will not make edits to the Perforce system. All
|
18
19
|
# modifying methods lie within this Client object, which typically binds to
|
19
20
|
# a single RPC call.
|
20
|
-
#
|
21
|
-
# TODO: URL to online documentation
|
22
21
|
class Client
|
23
22
|
# This is an instance of P4WebApiClient::Connection
|
24
23
|
attr_accessor :connection
|
@@ -30,8 +29,9 @@ module P4WebApiClient
|
|
30
29
|
#
|
31
30
|
# Any client created via Client.new should take care to call close().
|
32
31
|
#
|
33
|
-
def initialize(
|
34
|
-
|
32
|
+
def initialize(conn)
|
33
|
+
conn = Connection.new(conn) unless conn.is_a?(Connection)
|
34
|
+
@connection = conn
|
35
35
|
end
|
36
36
|
|
37
37
|
def close
|
@@ -73,13 +73,13 @@ end
|
|
73
73
|
require 'p4_web_api_client/client/branches'
|
74
74
|
require 'p4_web_api_client/client/changes'
|
75
75
|
require 'p4_web_api_client/client/clients'
|
76
|
+
require 'p4_web_api_client/client/commands'
|
76
77
|
require 'p4_web_api_client/client/depots'
|
77
78
|
require 'p4_web_api_client/client/files'
|
78
79
|
require 'p4_web_api_client/client/groups'
|
79
80
|
require 'p4_web_api_client/client/jobs'
|
80
81
|
require 'p4_web_api_client/client/labels'
|
81
82
|
require 'p4_web_api_client/client/protections'
|
82
|
-
require 'p4_web_api_client/client/run'
|
83
83
|
require 'p4_web_api_client/client/servers'
|
84
84
|
require 'p4_web_api_client/client/streams'
|
85
85
|
require 'p4_web_api_client/client/triggers'
|
@@ -26,7 +26,7 @@ module P4WebApiClient
|
|
26
26
|
|
27
27
|
# Updates the branch specification.
|
28
28
|
def update_branch(branch)
|
29
|
-
execute_method_with_body(:
|
29
|
+
execute_method_with_body(:patch, "/branches/#{URI.encode(branch.branch)}",
|
30
30
|
branch.to_internal_hash)
|
31
31
|
true
|
32
32
|
end
|
@@ -13,5 +13,20 @@ module P4WebApiClient
|
|
13
13
|
arr = execute_method_no_body(:get, '/changes', options)
|
14
14
|
arr.map { |obj| Models::Change.new(obj) }
|
15
15
|
end
|
16
|
+
|
17
|
+
# Returns the Change indicated by the change number or model.
|
18
|
+
#
|
19
|
+
# If there are files submitted with the change, the change.files field
|
20
|
+
# should be filled out.
|
21
|
+
def change(change)
|
22
|
+
change_id = change.is_a?(Models::Change) ? change.change : change
|
23
|
+
arr = execute_method_no_body(:get, "/changes/#{change_id}")
|
24
|
+
Models::Change.new(arr.first)
|
25
|
+
end
|
26
|
+
|
27
|
+
def create_change(change)
|
28
|
+
change = Models::Change.new(change) unless change.is_a?(Models::Change)
|
29
|
+
execute_method_with_body(:post, '/changes', nil, change.to_internal_hash)
|
30
|
+
end
|
16
31
|
end
|
17
32
|
end
|
@@ -25,7 +25,7 @@ module P4WebApiClient
|
|
25
25
|
|
26
26
|
# Updates the client specification.
|
27
27
|
def update_client(client)
|
28
|
-
execute_method_with_body(:
|
28
|
+
execute_method_with_body(:patch, "/clients/#{URI.encode(client.client)}",
|
29
29
|
client.to_internal_hash)
|
30
30
|
true
|
31
31
|
end
|
@@ -1,17 +1,21 @@
|
|
1
1
|
require 'json'
|
2
|
+
require 'open-uri'
|
2
3
|
|
3
4
|
module P4WebApiClient
|
4
5
|
class Client
|
5
|
-
#
|
6
|
+
# Execute a Perforce command.
|
6
7
|
#
|
7
8
|
# First argument should always be the command, followed by command line
|
8
9
|
# arguments.
|
9
10
|
#
|
10
11
|
# Expect to always have an array of hashes as output.
|
11
|
-
|
12
|
+
#
|
13
|
+
# Not all commands are allowed, since the command will be executed on the
|
14
|
+
# web server. In general, if your command requires a client workspace, it
|
15
|
+
# will likely fail, or be blocked.
|
16
|
+
def exec(cmd, *args)
|
12
17
|
params = arg_params(args)
|
13
|
-
|
14
|
-
execute_method_no_body(:get, '/run', params)
|
18
|
+
execute_method_no_body(:get, "/commands/#{URI.encode(cmd)}", params)
|
15
19
|
end
|
16
20
|
|
17
21
|
# Generic run command with and input body.
|
@@ -20,10 +24,15 @@ module P4WebApiClient
|
|
20
24
|
# then followed by additional command line arguments.
|
21
25
|
#
|
22
26
|
# Expect the output to always be an array of hashes.
|
23
|
-
|
27
|
+
#
|
28
|
+
# Not all commands are allowed, since the command will be executed on the
|
29
|
+
# web server. In general, if your command requires a client workspace, it
|
30
|
+
# will likely fail, or be blocked.
|
31
|
+
def execi(cmd, input, *args)
|
24
32
|
params = arg_params(args)
|
25
33
|
params[:cmd] = cmd
|
26
|
-
|
34
|
+
path = "/commands/#{URI.encode(cmd)}"
|
35
|
+
execute_method_with_body(:post, path, params, input)
|
27
36
|
end
|
28
37
|
|
29
38
|
# Creates a hash and creates keys 'arg1', 'arg2', etc that points to
|
@@ -27,7 +27,7 @@ module P4WebApiClient
|
|
27
27
|
|
28
28
|
# Updates the depot specification.
|
29
29
|
def update_depot(depot)
|
30
|
-
execute_method_with_body(:
|
30
|
+
execute_method_with_body(:patch, "/depots/#{URI.encode(depot.depot)}",
|
31
31
|
depot.to_internal_hash)
|
32
32
|
true
|
33
33
|
end
|
@@ -2,7 +2,6 @@ require 'open-uri'
|
|
2
2
|
require 'p4_web_api_client/models/dir'
|
3
3
|
require 'p4_web_api_client/models/depot'
|
4
4
|
require 'p4_web_api_client/models/file'
|
5
|
-
require 'p4_web_api_client/models/upload_file'
|
6
5
|
|
7
6
|
module P4WebApiClient
|
8
7
|
class Client
|
@@ -12,79 +11,85 @@ module P4WebApiClient
|
|
12
11
|
# depot location, e.g., `my_depot/dir1`.
|
13
12
|
#
|
14
13
|
# When path is empty, will return the list of depots.
|
14
|
+
#
|
15
|
+
# Note: if path happens to be a file, instead of a directory, this is
|
16
|
+
# a synonym with the file() method.
|
15
17
|
def files(path = '')
|
16
18
|
unless path.empty?
|
17
19
|
path = path.split('/').map { |p| URI.encode(p) }.join('/')
|
18
20
|
end
|
19
21
|
arr = execute_method_no_body(:get, "/files/#{path}")
|
20
|
-
arr.
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
22
|
+
if arr.is_a?(Array)
|
23
|
+
arr.map do |obj|
|
24
|
+
if obj.key?('DepotFile')
|
25
|
+
Models::File.new(obj)
|
26
|
+
elsif obj.key?('Dir')
|
27
|
+
Models::Dir.new(obj)
|
28
|
+
elsif obj.key?('Depot')
|
29
|
+
Models::Depot.new(obj)
|
30
|
+
end
|
27
31
|
end
|
32
|
+
else
|
33
|
+
Models::File.new(arr)
|
28
34
|
end
|
29
35
|
end
|
30
36
|
|
31
|
-
# Returns the
|
37
|
+
# Returns the file metadata at this location, with the `content` field
|
38
|
+
# filled out.
|
32
39
|
#
|
33
|
-
#
|
34
|
-
#
|
35
|
-
def
|
36
|
-
|
37
|
-
|
38
|
-
path = path.gsub(/^[\/]*/, '') # Strip leading slashes
|
40
|
+
# If path happens to be a directory, this method is synonymous with the
|
41
|
+
# files() method.
|
42
|
+
def file(path)
|
43
|
+
files(path)
|
44
|
+
end
|
39
45
|
|
40
|
-
|
41
|
-
|
42
|
-
|
46
|
+
# Upload a single file's content.
|
47
|
+
#
|
48
|
+
# file should contain the following fields:
|
49
|
+
#
|
50
|
+
# - `depot_file`: target depot path
|
51
|
+
# - `content`: file content
|
52
|
+
def upload_file(file)
|
53
|
+
file = Models::File.new(file) unless file.is_a?(Models::File)
|
54
|
+
path = encode_path(file.depot_file)
|
55
|
+
execute_method_with_body(:patch,
|
56
|
+
"/files/#{path}",
|
57
|
+
nil,
|
58
|
+
file.to_internal_hash)
|
43
59
|
end
|
44
60
|
|
45
|
-
#
|
61
|
+
# Upload multiple files
|
46
62
|
#
|
47
|
-
#
|
48
|
-
# hashes that will be turned into those UploadFile definitions. Which means
|
49
|
-
# that each hash should include the following properties:
|
63
|
+
# Each file in the files array should have two fields
|
50
64
|
#
|
51
|
-
# - `
|
52
|
-
# - `content`:
|
53
|
-
# or it can be an IO handle, which we'll just read
|
54
|
-
# - `content_type`: If not set, we'll assume `application/octet-stream`
|
65
|
+
# - `depot_file`: target path, can be relative if `path` is indicated
|
66
|
+
# - `content`: File content
|
55
67
|
#
|
56
|
-
#
|
57
|
-
#
|
58
|
-
def
|
59
|
-
|
60
|
-
|
61
|
-
post_body = {
|
62
|
-
mappings: file_models.map(&:depot_path)
|
63
|
-
}
|
64
|
-
|
65
|
-
file_models.each_index do |idx|
|
66
|
-
key = "file_#{idx}"
|
67
|
-
post_body[key.to_sym] = file_models[idx].upload_io
|
68
|
+
# The optional `path` parameter can indicate the root directory for all
|
69
|
+
# files.
|
70
|
+
def upload_files(files: [], path: nil)
|
71
|
+
files = files.map do |f|
|
72
|
+
Models::File.new(f) unless f.is_a?(Models::File)
|
68
73
|
end
|
69
74
|
|
70
|
-
|
75
|
+
path = path ? encode_path(path) : ''
|
76
|
+
|
77
|
+
obj = {
|
78
|
+
'Files' => files.map(&:to_internal_hash)
|
79
|
+
}
|
71
80
|
|
72
|
-
|
81
|
+
execute_method_with_body(:patch, "/files/#{path}", nil, obj)
|
82
|
+
end
|
73
83
|
|
74
|
-
|
84
|
+
def delete_file(path)
|
85
|
+
path = encode_path(path)
|
86
|
+
execute_method_no_body(:delete, "/files/#{path}")
|
75
87
|
end
|
76
88
|
|
77
89
|
private
|
78
90
|
|
79
|
-
def
|
80
|
-
|
81
|
-
files.each do |file|
|
82
|
-
unless file.is_a?(Models::UploadFile)
|
83
|
-
file = Models::UploadFile.new(file)
|
84
|
-
end
|
85
|
-
file_models << file
|
86
|
-
end
|
87
|
-
file_models
|
91
|
+
def encode_path(path)
|
92
|
+
path.split('/').map { |p| URI.encode(p) }.join('/')
|
88
93
|
end
|
89
94
|
end
|
90
95
|
end
|
@@ -26,7 +26,7 @@ module P4WebApiClient
|
|
26
26
|
|
27
27
|
# Updates the group specification.
|
28
28
|
def update_group(group)
|
29
|
-
execute_method_with_body(:
|
29
|
+
execute_method_with_body(:patch, "/groups/#{URI.encode(group.group)}",
|
30
30
|
group.to_internal_hash)
|
31
31
|
true
|
32
32
|
end
|
@@ -26,7 +26,7 @@ module P4WebApiClient
|
|
26
26
|
|
27
27
|
# Updates the label specification.
|
28
28
|
def update_label(label)
|
29
|
-
execute_method_with_body(:
|
29
|
+
execute_method_with_body(:patch, "/labels/#{URI.encode(label.label)}",
|
30
30
|
label.to_internal_hash)
|
31
31
|
true
|
32
32
|
end
|
@@ -24,7 +24,8 @@ module P4WebApiClient
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def update_server(server)
|
27
|
-
execute_method_with_body(:
|
27
|
+
execute_method_with_body(:patch,
|
28
|
+
"/servers/#{URI.encode(server.server_id)}",
|
28
29
|
server.to_internal_hash)
|
29
30
|
true
|
30
31
|
end
|
@@ -6,14 +6,14 @@ module P4WebApiClient
|
|
6
6
|
# Adds common configuration to the Faraday connection, like, the host name,
|
7
7
|
# version, and context prefixes.
|
8
8
|
class Connection
|
9
|
-
attr_accessor :
|
9
|
+
attr_accessor :user, :prefix, :session_token
|
10
10
|
|
11
11
|
# See the options for Faraday.new, plus, the following fields:
|
12
|
-
# - :
|
12
|
+
# - :user
|
13
13
|
# - :password
|
14
14
|
# - :prefix - defaults to '/v1'
|
15
|
-
def initialize(options
|
16
|
-
local_opts = [:
|
15
|
+
def initialize(options)
|
16
|
+
local_opts = [:user, :password, :prefix]
|
17
17
|
conn_options = options.select { |k| !local_opts.include?(k) }
|
18
18
|
|
19
19
|
@conn = Faraday.new(conn_options) do |conn|
|
@@ -23,14 +23,14 @@ module P4WebApiClient
|
|
23
23
|
end
|
24
24
|
|
25
25
|
@session_token = nil
|
26
|
-
@
|
26
|
+
@user = options[:user]
|
27
27
|
@prefix = options.key?(:prefix) ? options[:prefix] : '/v1'
|
28
28
|
|
29
29
|
# When we're not initialized with a password, we may be on a insecure
|
30
30
|
# server, so don't even log in.
|
31
31
|
if options[:password] && !Connection.p4_ticket?(options[:password])
|
32
32
|
response = @conn.post(path_for('/sessions'),
|
33
|
-
|
33
|
+
user: @user,
|
34
34
|
password: options[:password])
|
35
35
|
assert_ok(response)
|
36
36
|
|
@@ -40,7 +40,7 @@ module P4WebApiClient
|
|
40
40
|
# we don't generate the session token
|
41
41
|
@session_token = options[:password] || ''
|
42
42
|
end
|
43
|
-
@conn.basic_auth(
|
43
|
+
@conn.basic_auth(user, session_token)
|
44
44
|
end
|
45
45
|
|
46
46
|
def self.p4_ticket?(str)
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# Copyright (c) 2014 Perforce Software, Inc. All rights reserved.
|
2
2
|
|
3
|
+
require 'base64'
|
3
4
|
require 'time'
|
4
5
|
|
5
6
|
module P4WebApiClient
|
@@ -42,7 +43,8 @@ module P4WebApiClient
|
|
42
43
|
# An array of job IDs fixed by this changelist
|
43
44
|
attr_accessor :jobs
|
44
45
|
|
45
|
-
# An array of
|
46
|
+
# An array of Change::File models for this changelist, which describe
|
47
|
+
# the kinds of edits to the changelist.
|
46
48
|
attr_accessor :files
|
47
49
|
|
48
50
|
def initialize(obj = {})
|
@@ -65,6 +67,77 @@ module P4WebApiClient
|
|
65
67
|
accessor = "#{key}="
|
66
68
|
send(accessor, obj[key]) if self.respond_to?(accessor)
|
67
69
|
end
|
70
|
+
|
71
|
+
@files = @files.map do |file|
|
72
|
+
file = Change::File.new(file) unless file.is_a?(Change::File)
|
73
|
+
file
|
74
|
+
end if @files && !@files.empty?
|
75
|
+
end
|
76
|
+
|
77
|
+
def to_internal_hash
|
78
|
+
{
|
79
|
+
'Description' => description,
|
80
|
+
'Files' => files.map(&:to_internal_hash)
|
81
|
+
}
|
82
|
+
end
|
83
|
+
|
84
|
+
# Metadata related to files changed in a particular changelist.
|
85
|
+
class File
|
86
|
+
# The depot path to the file
|
87
|
+
attr_accessor :depot_file
|
88
|
+
|
89
|
+
# The action, one of :add, :edit, :branch, :move, :move_delete,
|
90
|
+
# :move_add, :upload
|
91
|
+
attr_accessor :action
|
92
|
+
|
93
|
+
# The Perforce file type, e.g., :text
|
94
|
+
attr_accessor :type
|
95
|
+
|
96
|
+
# The file revision number created by this changelist
|
97
|
+
attr_accessor :revision
|
98
|
+
|
99
|
+
# If saved, the size of the file in bytes
|
100
|
+
attr_accessor :file_size
|
101
|
+
|
102
|
+
# The digest of changes for this file, available if it's been serialized
|
103
|
+
attr_accessor :digest
|
104
|
+
|
105
|
+
# For actions like :branch, or :move, this should be specified by the
|
106
|
+
# the client code to indicate the source of the action. This will *not*
|
107
|
+
# be set by the server.
|
108
|
+
attr_accessor :from_depot_file
|
109
|
+
|
110
|
+
# Content of the file, probably only set when uploading multiple files
|
111
|
+
# via the client.create_change() method
|
112
|
+
attr_accessor :content
|
113
|
+
|
114
|
+
def initialize(obj = {})
|
115
|
+
@depot_file = obj['DepotFile'] if obj.key?('DepotFile')
|
116
|
+
@action = obj['Action'].gsub(/\//, '_').to_sym if obj.key?('Action')
|
117
|
+
@type = obj['Type'].to_sym if obj.key?('Type')
|
118
|
+
@revision = obj['Revision'].to_i if obj.key?('Revision')
|
119
|
+
@file_size = obj['FileSize'].to_i if obj.key?('FileSize')
|
120
|
+
@digest = obj['Digest'] if obj.key?('Digest')
|
121
|
+
@from_depot_file = obj['FromDepotFile'] if obj.key('FromDepotFile')
|
122
|
+
@content = obj['Content'] if obj.key?('Content')
|
123
|
+
|
124
|
+
# If the user has defined symbols in the Ruby-ish API, then use that
|
125
|
+
# too, but we expect the data to be in the right format.
|
126
|
+
obj.each_key do |key|
|
127
|
+
accessor = "#{key}="
|
128
|
+
send(accessor, obj[key]) if self.respond_to?(accessor)
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
def to_internal_hash
|
133
|
+
obj = {
|
134
|
+
'DepotFile' => depot_file,
|
135
|
+
'Action' => action.to_s.gsub(/_/, '/')
|
136
|
+
}
|
137
|
+
obj['FromDepotFile'] = from_depot_file if from_depot_file
|
138
|
+
obj['Content'] = Base64.encode64(content) if content
|
139
|
+
obj
|
140
|
+
end
|
68
141
|
end
|
69
142
|
end
|
70
143
|
end
|
@@ -37,6 +37,10 @@ module P4WebApiClient
|
|
37
37
|
# DateTime of when the file revision was created
|
38
38
|
attr_accessor :date
|
39
39
|
|
40
|
+
# The content of the file, only created by requests to the client.file
|
41
|
+
# method.
|
42
|
+
attr_accessor :content
|
43
|
+
|
40
44
|
def initialize(obj = {})
|
41
45
|
@depot_file = obj['DepotFile'] if obj.key?('DepotFile')
|
42
46
|
@revision = obj['Revision'].to_i if obj.key?('Revision')
|
@@ -45,6 +49,8 @@ module P4WebApiClient
|
|
45
49
|
@type = obj['Type'].to_sym if obj.key?('Type')
|
46
50
|
@date = Time.at(obj['Date']).to_datetime if obj.key?('Date')
|
47
51
|
|
52
|
+
@content = Base64.decode64(obj['Content']) if obj.key?('Content')
|
53
|
+
|
48
54
|
# If the user has defined symbols in the Ruby-ish API, then use that
|
49
55
|
# too, but we expect the data to be in the right format.
|
50
56
|
obj.each_key do |key|
|
@@ -65,6 +71,13 @@ module P4WebApiClient
|
|
65
71
|
def name
|
66
72
|
depot_file.split('/').last
|
67
73
|
end
|
74
|
+
|
75
|
+
def to_internal_hash
|
76
|
+
{
|
77
|
+
'DepotFile' => depot_file,
|
78
|
+
'Content' => Base64.encode64(content)
|
79
|
+
}
|
80
|
+
end
|
68
81
|
end
|
69
82
|
end
|
70
83
|
end
|
data/spec/branches_spec.rb
CHANGED
@@ -5,7 +5,6 @@ require 'p4_web_api_client'
|
|
5
5
|
require 'test_connections'
|
6
6
|
|
7
7
|
RSpec.describe P4WebApiClient::Client, '#create_branch' do
|
8
|
-
|
9
8
|
it 'should create a new branch - and return it via #branches' do
|
10
9
|
client_as_jdoe do |c|
|
11
10
|
new_branch = P4WebApiClient::Models::Branch.new
|
@@ -22,7 +21,6 @@ RSpec.describe P4WebApiClient::Client, '#create_branch' do
|
|
22
21
|
end
|
23
22
|
|
24
23
|
RSpec.describe P4WebApiClient::Client, '#branch' do
|
25
|
-
|
26
24
|
it 'should load a single branch created via #create_branch' do
|
27
25
|
client_as_jdoe do |c|
|
28
26
|
new_branch = c.branch('new_branch')
|
@@ -36,7 +34,6 @@ RSpec.describe P4WebApiClient::Client, '#branch' do
|
|
36
34
|
end
|
37
35
|
|
38
36
|
RSpec.describe P4WebApiClient::Client, '#update_branch' do
|
39
|
-
|
40
37
|
it "'should be able to update the branch description'" do
|
41
38
|
client_as_jdoe do |c|
|
42
39
|
new_branch = c.branch('new_branch')
|
@@ -51,7 +48,6 @@ RSpec.describe P4WebApiClient::Client, '#update_branch' do
|
|
51
48
|
end
|
52
49
|
|
53
50
|
RSpec.describe P4WebApiClient::Client, '#delete_branch' do
|
54
|
-
|
55
51
|
it "'should be able to delete a branch created via #create_branch'" do
|
56
52
|
client_as_jdoe do |c|
|
57
53
|
c.delete_branch('new_branch')
|
data/spec/change_spec.rb
CHANGED
@@ -5,7 +5,6 @@ require 'p4_web_api_client'
|
|
5
5
|
require 'test_connections'
|
6
6
|
|
7
7
|
RSpec.describe P4WebApiClient::Client, '#changes' do
|
8
|
-
|
9
8
|
it 'should list change 1' do
|
10
9
|
client_as_jdoe do |c|
|
11
10
|
changes = c.changes
|
@@ -14,3 +13,57 @@ RSpec.describe P4WebApiClient::Client, '#changes' do
|
|
14
13
|
end
|
15
14
|
end
|
16
15
|
end
|
16
|
+
|
17
|
+
RSpec.describe P4WebApiClient::Client, '#change' do
|
18
|
+
it 'should describe two files in change 1' do
|
19
|
+
client_as_jdoe do |c|
|
20
|
+
change = c.change('1')
|
21
|
+
expect(change.files.length).to eq(2)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
RSpec.describe P4WebApiClient::Client, '#create_change' do
|
27
|
+
it 'should allow us to integrate //depot/dev/Experimental to '\
|
28
|
+
'//depot/main/Experimental' do
|
29
|
+
client_as_jdoe do |c|
|
30
|
+
c.create_change(
|
31
|
+
'files' => [
|
32
|
+
{
|
33
|
+
'depot_file' => '//depot/main/Experimental/...',
|
34
|
+
'from_depot_file' => '//depot/dev/Experimental/...',
|
35
|
+
'action' => 'branch'
|
36
|
+
}
|
37
|
+
]
|
38
|
+
)
|
39
|
+
files = c.files('//depot/main/Experimental')
|
40
|
+
expect(files.length).to eq(1)
|
41
|
+
expect(files.first.name).to eq('README')
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'should allow us to upload two files to //depot/dev/Experimental' do
|
46
|
+
client_as_jdoe do |c|
|
47
|
+
c.create_change(
|
48
|
+
'description' => 'Upload two experimental files',
|
49
|
+
'files' => [
|
50
|
+
{
|
51
|
+
'depot_file' => '//depot/dev/Experimental/teapot1.txt',
|
52
|
+
'action' => 'upload',
|
53
|
+
'content' => "I'm a little teapot"
|
54
|
+
},
|
55
|
+
{
|
56
|
+
'depot_file' => '//depot/dev/Experimental/teapot2.txt',
|
57
|
+
'action' => 'upload',
|
58
|
+
'content' => 'Short and stout!'
|
59
|
+
}
|
60
|
+
]
|
61
|
+
)
|
62
|
+
|
63
|
+
files = c.files('//depot/dev/Experimental')
|
64
|
+
names = files.map(&:name)
|
65
|
+
expect(names).to include('teapot1.txt')
|
66
|
+
expect(names).to include('teapot2.txt')
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
data/spec/clients_spec.rb
CHANGED
@@ -5,7 +5,6 @@ require 'p4_web_api_client'
|
|
5
5
|
require 'test_connections'
|
6
6
|
|
7
7
|
RSpec.describe P4WebApiClient::Client, '#create_client' do
|
8
|
-
|
9
8
|
it 'should create a new client - and return it via #clients' do
|
10
9
|
client_as_jdoe do |c|
|
11
10
|
new_client = P4WebApiClient::Models::Client.new
|
@@ -23,7 +22,6 @@ RSpec.describe P4WebApiClient::Client, '#create_client' do
|
|
23
22
|
end
|
24
23
|
|
25
24
|
RSpec.describe P4WebApiClient::Client, '#client' do
|
26
|
-
|
27
25
|
it 'should load a single client created via #create_client' do
|
28
26
|
client_as_jdoe do |c|
|
29
27
|
new_client = c.client('new_client')
|
@@ -37,7 +35,6 @@ RSpec.describe P4WebApiClient::Client, '#client' do
|
|
37
35
|
end
|
38
36
|
|
39
37
|
RSpec.describe P4WebApiClient::Client, '#update_client' do
|
40
|
-
|
41
38
|
it "'should be able to update the client description'" do
|
42
39
|
client_as_jdoe do |c|
|
43
40
|
new_client = c.client('new_client')
|
@@ -52,7 +49,6 @@ RSpec.describe P4WebApiClient::Client, '#update_client' do
|
|
52
49
|
end
|
53
50
|
|
54
51
|
RSpec.describe P4WebApiClient::Client, '#delete_client' do
|
55
|
-
|
56
52
|
it "'should be able to delete a client created via #create_client'" do
|
57
53
|
client_as_jdoe do |c|
|
58
54
|
c.delete_client('new_client')
|
data/spec/depots_spec.rb
CHANGED
@@ -6,7 +6,6 @@ require 'p4_web_api_client'
|
|
6
6
|
require 'test_connections'
|
7
7
|
|
8
8
|
RSpec.describe P4WebApiClient::Client, '#create_depot' do
|
9
|
-
|
10
9
|
it 'should create a new depot - and return it via #depots' do
|
11
10
|
client_as_jdoe do |c|
|
12
11
|
new_depot = P4WebApiClient::Models::Depot.new
|
@@ -24,7 +23,6 @@ RSpec.describe P4WebApiClient::Client, '#create_depot' do
|
|
24
23
|
end
|
25
24
|
|
26
25
|
RSpec.describe P4WebApiClient::Client, '#depot' do
|
27
|
-
|
28
26
|
it 'should load a single depot created via #create_depot' do
|
29
27
|
client_as_jdoe do |c|
|
30
28
|
new_depot = c.depot('new_depot')
|
@@ -35,7 +33,6 @@ RSpec.describe P4WebApiClient::Client, '#depot' do
|
|
35
33
|
end
|
36
34
|
|
37
35
|
RSpec.describe P4WebApiClient::Client, '#update_depot' do
|
38
|
-
|
39
36
|
it "'should be able to update the depot description'" do
|
40
37
|
client_as_jdoe do |c|
|
41
38
|
new_depot = c.depot('new_depot')
|
@@ -50,7 +47,6 @@ RSpec.describe P4WebApiClient::Client, '#update_depot' do
|
|
50
47
|
end
|
51
48
|
|
52
49
|
RSpec.describe P4WebApiClient::Client, '#delete_depot' do
|
53
|
-
|
54
50
|
it "'should be able to delete a depot created via #create_depot'" do
|
55
51
|
client_as_jdoe do |c|
|
56
52
|
c.delete_depot('new_depot')
|
@@ -9,11 +9,10 @@ require 'p4_web_api_client'
|
|
9
9
|
|
10
10
|
require 'test_connections'
|
11
11
|
|
12
|
-
RSpec.describe P4WebApiClient::Client, '#
|
13
|
-
|
12
|
+
RSpec.describe P4WebApiClient::Client, '#exec' do
|
14
13
|
it "should allow us to run 'user -o' for our known user" do
|
15
14
|
client_as_super do |c|
|
16
|
-
results = c.
|
15
|
+
results = c.exec('user', '-o')
|
17
16
|
expect(results.length).to eq(1)
|
18
17
|
expect(results[0]['User']).to eq('super')
|
19
18
|
end
|
@@ -7,8 +7,7 @@ require 'p4_web_api_client'
|
|
7
7
|
|
8
8
|
require 'test_connections'
|
9
9
|
|
10
|
-
RSpec.describe P4WebApiClient::Client, '#
|
11
|
-
|
10
|
+
RSpec.describe P4WebApiClient::Client, '#execi' do
|
12
11
|
it "should allow us to run 'user -f joeuser' to create a new user" do
|
13
12
|
client_as_super do |c|
|
14
13
|
input = {
|
@@ -16,7 +15,7 @@ RSpec.describe P4WebApiClient::Client, '#run_input' do
|
|
16
15
|
'FullName' => 'Joe User',
|
17
16
|
'Email' => 'joeuser@example.com'
|
18
17
|
}
|
19
|
-
results = c.
|
18
|
+
results = c.execi('user', input, '-i', '-f')
|
20
19
|
expect(results.length).to eq(1)
|
21
20
|
end
|
22
21
|
end
|
data/spec/files_spec.rb
CHANGED
@@ -6,7 +6,6 @@ require 'tempfile'
|
|
6
6
|
require 'test_connections'
|
7
7
|
|
8
8
|
RSpec.describe P4WebApiClient::Client, '#files' do
|
9
|
-
|
10
9
|
it 'should list the depots with no arguments' do
|
11
10
|
client_as_jdoe do |c|
|
12
11
|
depots = c.files
|
@@ -28,66 +27,68 @@ RSpec.describe P4WebApiClient::Client, '#files' do
|
|
28
27
|
it "should list 'README' at the depot/dev/Experimental path" do
|
29
28
|
client_as_jdoe do |c|
|
30
29
|
paths = c.files('depot/dev/Experimental')
|
31
|
-
expect(paths.length).to eq(1)
|
32
30
|
names = paths.map(&:name)
|
33
31
|
expect(names).to include('README')
|
34
32
|
end
|
35
33
|
end
|
36
34
|
end
|
37
35
|
|
38
|
-
RSpec.describe P4WebApiClient::Client, '#
|
39
|
-
|
40
|
-
it 'should print the content of //depot/dev/Experimental/README' do
|
36
|
+
RSpec.describe P4WebApiClient::Client, '#upload_file' do
|
37
|
+
it 'should allow me to upload a new README to depot/dev/Experimental' do
|
41
38
|
client_as_jdoe do |c|
|
42
|
-
|
43
|
-
|
39
|
+
c.upload_file(
|
40
|
+
'depot_file' => '//depot/dev/Experimental/README',
|
41
|
+
'content' => 'This is the new damn readme!'
|
42
|
+
)
|
43
|
+
|
44
|
+
uploaded = c.file('//depot/dev/Experimental/README')
|
45
|
+
expect(uploaded.content).to eq('This is the new damn readme!')
|
44
46
|
end
|
45
47
|
end
|
46
48
|
end
|
47
49
|
|
48
|
-
RSpec.describe P4WebApiClient::Client, '#
|
49
|
-
|
50
|
-
|
50
|
+
RSpec.describe P4WebApiClient::Client, '#upload_files' do
|
51
|
+
it 'should allow me to upload the README and a new_file to '\
|
52
|
+
'depot/dev/Experimental' do
|
51
53
|
client_as_jdoe do |c|
|
52
|
-
|
53
|
-
|
54
|
-
new_up = Tempfile.new('new')
|
55
|
-
|
56
|
-
begin
|
57
|
-
exists_up.write('existing file content')
|
58
|
-
new_up.write('new file content')
|
59
|
-
|
60
|
-
exists_up.rewind
|
61
|
-
new_up.rewind
|
62
|
-
|
63
|
-
c.upload(
|
54
|
+
c.upload_files(
|
55
|
+
files:
|
64
56
|
[
|
65
57
|
{
|
66
|
-
|
67
|
-
content
|
58
|
+
'depot_file' => 'README',
|
59
|
+
'content' => 'Another readme version'
|
68
60
|
},
|
69
61
|
{
|
70
|
-
|
71
|
-
content
|
72
|
-
content_type: 'text/plain'
|
62
|
+
'depot_file' => 'new_file',
|
63
|
+
'content' => 'New file content'
|
73
64
|
}
|
74
|
-
]
|
75
|
-
|
65
|
+
],
|
66
|
+
path: '//depot/dev/Experimental'
|
67
|
+
)
|
76
68
|
|
77
|
-
|
78
|
-
|
79
|
-
|
69
|
+
files = c.files('//depot/dev/Experimental')
|
70
|
+
names = files.map(&:name)
|
71
|
+
expect(names).to include('README')
|
72
|
+
expect(names).to include('new_file')
|
80
73
|
|
81
|
-
|
82
|
-
|
83
|
-
end
|
74
|
+
readme_file = c.file('//depot/dev/Experimental/README')
|
75
|
+
expect(readme_file.content).to eq('Another readme version')
|
84
76
|
|
85
|
-
|
86
|
-
expect(
|
77
|
+
new_file = c.file('//depot/dev/Experimental/new_file')
|
78
|
+
expect(new_file.content).to eq('New file content')
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
RSpec.describe P4WebApiClient::Client, '#delete_file' do
|
84
|
+
it 'should allow me to delete depot/dev/Experimental/new_file' do
|
85
|
+
client_as_jdoe do |c|
|
86
|
+
c.delete_file('//depot/dev/Experimental/new_file')
|
87
87
|
|
88
|
-
|
89
|
-
expect(new_content.strip).to eq('new file content')
|
88
|
+
files = c.files('//depot/dev/Experimental')
|
90
89
|
|
90
|
+
names = files.map(&:name)
|
91
|
+
expect(names).to_not include('new_file')
|
91
92
|
end
|
92
93
|
end
|
93
94
|
end
|
data/spec/groups_spec.rb
CHANGED
@@ -6,7 +6,6 @@ require 'p4_web_api_client'
|
|
6
6
|
require 'test_connections'
|
7
7
|
|
8
8
|
RSpec.describe P4WebApiClient::Client, '#create_group' do
|
9
|
-
|
10
9
|
it 'should create a new group - and return it via #groups' do
|
11
10
|
client_as_jdoe do |c|
|
12
11
|
new_group = P4WebApiClient::Models::Group.new
|
@@ -24,7 +23,6 @@ RSpec.describe P4WebApiClient::Client, '#create_group' do
|
|
24
23
|
end
|
25
24
|
|
26
25
|
RSpec.describe P4WebApiClient::Client, '#group' do
|
27
|
-
|
28
26
|
it 'should load a single group created via #create_group' do
|
29
27
|
client_as_jdoe do |c|
|
30
28
|
jarjar = c.group('jarjar')
|
@@ -36,7 +34,6 @@ RSpec.describe P4WebApiClient::Client, '#group' do
|
|
36
34
|
end
|
37
35
|
|
38
36
|
RSpec.describe P4WebApiClient::Client, '#update_group' do
|
39
|
-
|
40
37
|
it "'should be able to add a group owner'" do
|
41
38
|
client_as_jdoe do |c|
|
42
39
|
jarjar = c.group('jarjar')
|
@@ -51,7 +48,6 @@ RSpec.describe P4WebApiClient::Client, '#update_group' do
|
|
51
48
|
end
|
52
49
|
|
53
50
|
RSpec.describe P4WebApiClient::Client, '#delete_group' do
|
54
|
-
|
55
51
|
it "'should be able to delete a group created via #create_group'" do
|
56
52
|
client_as_jdoe do |c|
|
57
53
|
c.delete_group('jarjar')
|
data/spec/jobs_spec.rb
CHANGED
@@ -8,7 +8,6 @@ require 'test_connections'
|
|
8
8
|
first_job_id = nil
|
9
9
|
|
10
10
|
RSpec.describe P4WebApiClient::Client, '#create_job' do
|
11
|
-
|
12
11
|
it 'should create a new job - and return it via #jobs' do
|
13
12
|
client_as_jdoe do |c|
|
14
13
|
new_job = {
|
@@ -27,7 +26,6 @@ RSpec.describe P4WebApiClient::Client, '#create_job' do
|
|
27
26
|
end
|
28
27
|
|
29
28
|
RSpec.describe P4WebApiClient::Client, '#job' do
|
30
|
-
|
31
29
|
it 'should load a single job created via #create_job' do
|
32
30
|
client_as_jdoe do |c|
|
33
31
|
loaded = c.job(first_job_id)
|
@@ -38,7 +36,6 @@ RSpec.describe P4WebApiClient::Client, '#job' do
|
|
38
36
|
end
|
39
37
|
|
40
38
|
RSpec.describe P4WebApiClient::Client, '#update_job' do
|
41
|
-
|
42
39
|
it "'should be able to change status'" do
|
43
40
|
client_as_jdoe do |c|
|
44
41
|
job = c.job(first_job_id)
|
@@ -54,7 +51,6 @@ RSpec.describe P4WebApiClient::Client, '#update_job' do
|
|
54
51
|
end
|
55
52
|
|
56
53
|
RSpec.describe P4WebApiClient::Client, '#delete_job' do
|
57
|
-
|
58
54
|
it "'should be able to delete a job created via #create_job'" do
|
59
55
|
client_as_jdoe do |c|
|
60
56
|
c.delete_job(first_job_id)
|
data/spec/labels_spec.rb
CHANGED
@@ -6,7 +6,6 @@ require 'p4_web_api_client'
|
|
6
6
|
require 'test_connections'
|
7
7
|
|
8
8
|
RSpec.describe P4WebApiClient::Client, '#create_label' do
|
9
|
-
|
10
9
|
it 'should create a new label - and return it via #labels' do
|
11
10
|
client_as_jdoe do |c|
|
12
11
|
new_label = P4WebApiClient::Models::Label.new
|
@@ -23,7 +22,6 @@ RSpec.describe P4WebApiClient::Client, '#create_label' do
|
|
23
22
|
end
|
24
23
|
|
25
24
|
RSpec.describe P4WebApiClient::Client, '#label' do
|
26
|
-
|
27
25
|
it 'should load a single label created via #create_label' do
|
28
26
|
client_as_jdoe do |c|
|
29
27
|
new_label = c.label('new_label')
|
@@ -35,7 +33,6 @@ RSpec.describe P4WebApiClient::Client, '#label' do
|
|
35
33
|
end
|
36
34
|
|
37
35
|
RSpec.describe P4WebApiClient::Client, '#update_label' do
|
38
|
-
|
39
36
|
it "'should be able to update the label description'" do
|
40
37
|
client_as_jdoe do |c|
|
41
38
|
new_label = c.label('new_label')
|
@@ -50,7 +47,6 @@ RSpec.describe P4WebApiClient::Client, '#update_label' do
|
|
50
47
|
end
|
51
48
|
|
52
49
|
RSpec.describe P4WebApiClient::Client, '#delete_label' do
|
53
|
-
|
54
50
|
it "'should be able to delete a label created via #create_label'" do
|
55
51
|
client_as_jdoe do |c|
|
56
52
|
c.delete_label('new_label')
|
@@ -4,7 +4,7 @@ require 'p4_web_api_client'
|
|
4
4
|
def client_as_jdoe
|
5
5
|
conn = P4WebApiClient::Connection.new(
|
6
6
|
url: 'http://localhost:4567/',
|
7
|
-
|
7
|
+
user: 'jdoe',
|
8
8
|
password: 'johndoe1A!',
|
9
9
|
prefix: '/v1'
|
10
10
|
)
|
@@ -17,7 +17,7 @@ end
|
|
17
17
|
def client_as_super
|
18
18
|
conn = P4WebApiClient::Connection.new(
|
19
19
|
url: 'http://localhost:4567/',
|
20
|
-
|
20
|
+
user: 'super',
|
21
21
|
password: 'superuser1A!',
|
22
22
|
prefix: '/v1'
|
23
23
|
)
|
data/spec/protections_spec.rb
CHANGED
@@ -6,7 +6,6 @@ require 'p4_web_api_client'
|
|
6
6
|
require 'test_connections'
|
7
7
|
|
8
8
|
RSpec.describe P4WebApiClient::Client, '#protections' do
|
9
|
-
|
10
9
|
it 'should return an array with at least two protections' do
|
11
10
|
client_as_super do |c|
|
12
11
|
p = c.protections
|
@@ -16,7 +15,6 @@ RSpec.describe P4WebApiClient::Client, '#protections' do
|
|
16
15
|
end
|
17
16
|
|
18
17
|
RSpec.describe P4WebApiClient::Client, '#update_protections' do
|
19
|
-
|
20
18
|
it 'should add a protections entry for the user jdoe' do
|
21
19
|
client_as_super do |c|
|
22
20
|
p = c.protections
|
data/spec/servers_spec.rb
CHANGED
@@ -6,7 +6,6 @@ require 'p4_web_api_client'
|
|
6
6
|
require 'test_connections'
|
7
7
|
|
8
8
|
RSpec.describe P4WebApiClient::Client, '#create_server' do
|
9
|
-
|
10
9
|
it 'should create a new server - and return it via #servers' do
|
11
10
|
client_as_jdoe do |c|
|
12
11
|
new_server = P4WebApiClient::Models::Server.new
|
@@ -24,7 +23,6 @@ RSpec.describe P4WebApiClient::Client, '#create_server' do
|
|
24
23
|
end
|
25
24
|
|
26
25
|
RSpec.describe P4WebApiClient::Client, '#server' do
|
27
|
-
|
28
26
|
it 'should load a single server created via #create_server' do
|
29
27
|
client_as_jdoe do |c|
|
30
28
|
new_server = c.server('new_server')
|
@@ -37,7 +35,6 @@ RSpec.describe P4WebApiClient::Client, '#server' do
|
|
37
35
|
end
|
38
36
|
|
39
37
|
RSpec.describe P4WebApiClient::Client, '#update_server' do
|
40
|
-
|
41
38
|
it "'should be able to update the server description'" do
|
42
39
|
client_as_jdoe do |c|
|
43
40
|
new_server = c.server('new_server')
|
@@ -52,7 +49,6 @@ RSpec.describe P4WebApiClient::Client, '#update_server' do
|
|
52
49
|
end
|
53
50
|
|
54
51
|
RSpec.describe P4WebApiClient::Client, '#delete_server' do
|
55
|
-
|
56
52
|
it "'should be able to delete a server created via #create_server'" do
|
57
53
|
client_as_jdoe do |c|
|
58
54
|
c.delete_server('new_server')
|
data/spec/streams_spec.rb
CHANGED
@@ -6,7 +6,6 @@ require 'p4_web_api_client'
|
|
6
6
|
require 'test_connections'
|
7
7
|
|
8
8
|
RSpec.describe P4WebApiClient::Client, '#create_stream' do
|
9
|
-
|
10
9
|
it 'should create a new stream - and return it via #streams' do
|
11
10
|
client_as_jdoe do |c|
|
12
11
|
new_depot = P4WebApiClient::Models::Depot.new
|
@@ -34,7 +33,6 @@ RSpec.describe P4WebApiClient::Client, '#create_stream' do
|
|
34
33
|
end
|
35
34
|
|
36
35
|
RSpec.describe P4WebApiClient::Client, '#stream' do
|
37
|
-
|
38
36
|
it 'should load a single stream created via #create_stream' do
|
39
37
|
client_as_jdoe do |c|
|
40
38
|
new_stream = c.stream('//stuffs/new_stream')
|
@@ -47,7 +45,6 @@ RSpec.describe P4WebApiClient::Client, '#stream' do
|
|
47
45
|
end
|
48
46
|
|
49
47
|
RSpec.describe P4WebApiClient::Client, '#update_stream' do
|
50
|
-
|
51
48
|
it "'should be able to update the stream description'" do
|
52
49
|
client_as_jdoe do |c|
|
53
50
|
new_stream = c.stream('//stuffs/new_stream')
|
@@ -62,7 +59,6 @@ RSpec.describe P4WebApiClient::Client, '#update_stream' do
|
|
62
59
|
end
|
63
60
|
|
64
61
|
RSpec.describe P4WebApiClient::Client, '#delete_stream' do
|
65
|
-
|
66
62
|
it "'should be able to delete a stream created via #create_stream'" do
|
67
63
|
client_as_jdoe do |c|
|
68
64
|
c.delete_stream('//stuffs/new_stream')
|
data/spec/triggers_spec.rb
CHANGED
@@ -6,7 +6,6 @@ require 'p4_web_api_client'
|
|
6
6
|
require 'test_connections'
|
7
7
|
|
8
8
|
RSpec.describe P4WebApiClient::Client, '#triggers' do
|
9
|
-
|
10
9
|
it 'should allow us to update and fetch a new example trigger line' do
|
11
10
|
client_as_super do |c|
|
12
11
|
t = c.triggers
|
@@ -19,4 +18,14 @@ RSpec.describe P4WebApiClient::Client, '#triggers' do
|
|
19
18
|
end
|
20
19
|
end
|
21
20
|
|
21
|
+
it 'should allow us to clear out the triggers table' do
|
22
|
+
client_as_super do |c|
|
23
|
+
triggers = c.triggers
|
24
|
+
triggers.triggers = []
|
25
|
+
c.update_triggers(triggers)
|
26
|
+
|
27
|
+
updated = c.triggers
|
28
|
+
expect(updated.triggers.length).to eq(0)
|
29
|
+
end
|
30
|
+
end
|
22
31
|
end
|
data/spec/users_spec.rb
CHANGED
@@ -6,7 +6,6 @@ require 'p4_web_api_client'
|
|
6
6
|
require 'test_connections'
|
7
7
|
|
8
8
|
RSpec.describe P4WebApiClient::Client, '#users' do
|
9
|
-
|
10
9
|
it "should at least return the 'jdoe' and 'super' users" do
|
11
10
|
client_as_jdoe do |c|
|
12
11
|
users = c.users
|
@@ -19,7 +18,6 @@ RSpec.describe P4WebApiClient::Client, '#users' do
|
|
19
18
|
end
|
20
19
|
|
21
20
|
RSpec.describe P4WebApiClient::Client, '#user' do
|
22
|
-
|
23
21
|
it "should return the user 'mmustermann' who has the name 'Max Mustermann'" do
|
24
22
|
client_as_jdoe do |c|
|
25
23
|
max = c.user('mmustermann')
|
@@ -29,7 +27,6 @@ RSpec.describe P4WebApiClient::Client, '#user' do
|
|
29
27
|
end
|
30
28
|
|
31
29
|
RSpec.describe P4WebApiClient::Client, '#create_user' do
|
32
|
-
|
33
30
|
it 'should be able to create a new user and load it' do
|
34
31
|
client_as_jdoe do |c|
|
35
32
|
new_user = P4WebApiClient::Models::User.new
|
@@ -49,7 +46,6 @@ RSpec.describe P4WebApiClient::Client, '#create_user' do
|
|
49
46
|
end
|
50
47
|
|
51
48
|
RSpec.describe P4WebApiClient::Client, '#update_user' do
|
52
|
-
|
53
49
|
it "should be able update mmusterman's email to max_power@example.com" do
|
54
50
|
client_as_jdoe do |c|
|
55
51
|
max_user = c.user('mmustermann')
|
@@ -66,7 +62,6 @@ end
|
|
66
62
|
|
67
63
|
# I *think* this will run after the create_user spec if defined here.
|
68
64
|
RSpec.describe P4WebApiClient::Client, '#delete_user' do
|
69
|
-
|
70
65
|
it 'should be able to delete the newuser user' do
|
71
66
|
client_as_jdoe do |c|
|
72
67
|
c.delete_user('newuser')
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: p4_web_api_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2014.2.0.
|
4
|
+
version: 2014.2.0.pre4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tristan Juricek
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-12-
|
11
|
+
date: 2014-12-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -72,14 +72,14 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 2014.2.0.
|
75
|
+
version: 2014.2.0.pre4
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: 2014.2.0.
|
82
|
+
version: 2014.2.0.pre4
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: puma
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -191,13 +191,13 @@ files:
|
|
191
191
|
- lib/p4_web_api_client/client/branches.rb
|
192
192
|
- lib/p4_web_api_client/client/changes.rb
|
193
193
|
- lib/p4_web_api_client/client/clients.rb
|
194
|
+
- lib/p4_web_api_client/client/commands.rb
|
194
195
|
- lib/p4_web_api_client/client/depots.rb
|
195
196
|
- lib/p4_web_api_client/client/files.rb
|
196
197
|
- lib/p4_web_api_client/client/groups.rb
|
197
198
|
- lib/p4_web_api_client/client/jobs.rb
|
198
199
|
- lib/p4_web_api_client/client/labels.rb
|
199
200
|
- lib/p4_web_api_client/client/protections.rb
|
200
|
-
- lib/p4_web_api_client/client/run.rb
|
201
201
|
- lib/p4_web_api_client/client/servers.rb
|
202
202
|
- lib/p4_web_api_client/client/streams.rb
|
203
203
|
- lib/p4_web_api_client/client/triggers.rb
|
@@ -221,13 +221,14 @@ files:
|
|
221
221
|
- lib/p4_web_api_client/models/server.rb
|
222
222
|
- lib/p4_web_api_client/models/stream.rb
|
223
223
|
- lib/p4_web_api_client/models/triggers.rb
|
224
|
-
- lib/p4_web_api_client/models/upload_file.rb
|
225
224
|
- lib/p4_web_api_client/models/user.rb
|
226
225
|
- lib/p4_web_api_client/version.rb
|
227
226
|
- spec/branches_spec.rb
|
228
227
|
- spec/change_spec.rb
|
229
228
|
- spec/clients_spec.rb
|
230
229
|
- spec/depots_spec.rb
|
230
|
+
- spec/exec_spec.rb
|
231
|
+
- spec/execi_spec.rb
|
231
232
|
- spec/files_spec.rb
|
232
233
|
- spec/groups_spec.rb
|
233
234
|
- spec/init.base/init_p4d.rb
|
@@ -235,8 +236,6 @@ files:
|
|
235
236
|
- spec/labels_spec.rb
|
236
237
|
- spec/lib/test_connections.rb
|
237
238
|
- spec/protections_spec.rb
|
238
|
-
- spec/run_input_spec.rb
|
239
|
-
- spec/run_spec.rb
|
240
239
|
- spec/servers_spec.rb
|
241
240
|
- spec/streams_spec.rb
|
242
241
|
- spec/triggers_spec.rb
|
@@ -270,6 +269,8 @@ test_files:
|
|
270
269
|
- spec/change_spec.rb
|
271
270
|
- spec/clients_spec.rb
|
272
271
|
- spec/depots_spec.rb
|
272
|
+
- spec/exec_spec.rb
|
273
|
+
- spec/execi_spec.rb
|
273
274
|
- spec/files_spec.rb
|
274
275
|
- spec/groups_spec.rb
|
275
276
|
- spec/init.base/init_p4d.rb
|
@@ -277,8 +278,6 @@ test_files:
|
|
277
278
|
- spec/labels_spec.rb
|
278
279
|
- spec/lib/test_connections.rb
|
279
280
|
- spec/protections_spec.rb
|
280
|
-
- spec/run_input_spec.rb
|
281
|
-
- spec/run_spec.rb
|
282
281
|
- spec/servers_spec.rb
|
283
282
|
- spec/streams_spec.rb
|
284
283
|
- spec/triggers_spec.rb
|
@@ -1,42 +0,0 @@
|
|
1
|
-
# Copyright (c) 2014 Perforce Software, Inc. All rights reserved.
|
2
|
-
|
3
|
-
require 'faraday'
|
4
|
-
|
5
|
-
module P4WebApiClient
|
6
|
-
module Models
|
7
|
-
# Models each argument sent into the `client.upload` method. In general,
|
8
|
-
# you'll create hashes instead of these instances directly, so this class
|
9
|
-
# is 'hidden' in usage.
|
10
|
-
class UploadFile
|
11
|
-
# Where the file should go in the Perforce server.
|
12
|
-
attr_accessor :depot_path
|
13
|
-
|
14
|
-
# The IO handle to file data. Note that the initializer will open up
|
15
|
-
# 'content' properties as local files if specified as strings.
|
16
|
-
attr_accessor :content
|
17
|
-
|
18
|
-
# The MIME type we send the data as, defaults to
|
19
|
-
# `application/octet-stream`
|
20
|
-
attr_accessor :content_type
|
21
|
-
|
22
|
-
def initialize(obj = {})
|
23
|
-
@depot_path = obj[:depot_path]
|
24
|
-
|
25
|
-
@content = obj[:content]
|
26
|
-
@content = ::File.open(@content, 'r') if @content.is_a?(String)
|
27
|
-
|
28
|
-
@content_type = obj[:content_type]
|
29
|
-
@content_type = 'application/octet-stream' unless @content_type
|
30
|
-
end
|
31
|
-
|
32
|
-
def unique_file_name
|
33
|
-
random = (0...8).map { (65 + rand(26)).chr }.join
|
34
|
-
"#{random}_#{::File.basename(depot_path)}"
|
35
|
-
end
|
36
|
-
|
37
|
-
def upload_io
|
38
|
-
Faraday::UploadIO.new(content, content_type, unique_file_name)
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|