p4_web_api_client 2014.2.0.pre1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. checksums.yaml +7 -0
  2. data/lib/p4_web_api_client/client/branches.rb +41 -0
  3. data/lib/p4_web_api_client/client/changes.rb +17 -0
  4. data/lib/p4_web_api_client/client/clients.rb +40 -0
  5. data/lib/p4_web_api_client/client/depots.rb +42 -0
  6. data/lib/p4_web_api_client/client/files.rb +30 -0
  7. data/lib/p4_web_api_client/client/groups.rb +41 -0
  8. data/lib/p4_web_api_client/client/jobs.rb +36 -0
  9. data/lib/p4_web_api_client/client/labels.rb +41 -0
  10. data/lib/p4_web_api_client/client/protections.rb +19 -0
  11. data/lib/p4_web_api_client/client/run.rb +38 -0
  12. data/lib/p4_web_api_client/client/servers.rb +38 -0
  13. data/lib/p4_web_api_client/client/streams.rb +38 -0
  14. data/lib/p4_web_api_client/client/triggers.rb +18 -0
  15. data/lib/p4_web_api_client/client/users.rb +38 -0
  16. data/lib/p4_web_api_client/client.rb +86 -0
  17. data/lib/p4_web_api_client/connection.rb +98 -0
  18. data/lib/p4_web_api_client/errors/perforce_problem.rb +25 -0
  19. data/lib/p4_web_api_client/errors/resource_not_found.rb +10 -0
  20. data/lib/p4_web_api_client/errors/server_error.rb +9 -0
  21. data/lib/p4_web_api_client/errors/unauthenticated.rb +11 -0
  22. data/lib/p4_web_api_client/errors.rb +4 -0
  23. data/lib/p4_web_api_client/models/branch.rb +66 -0
  24. data/lib/p4_web_api_client/models/change.rb +71 -0
  25. data/lib/p4_web_api_client/models/client.rb +129 -0
  26. data/lib/p4_web_api_client/models/depot.rb +97 -0
  27. data/lib/p4_web_api_client/models/dir.rb +45 -0
  28. data/lib/p4_web_api_client/models/file.rb +70 -0
  29. data/lib/p4_web_api_client/models/group.rb +102 -0
  30. data/lib/p4_web_api_client/models/label.rb +75 -0
  31. data/lib/p4_web_api_client/models/protections.rb +34 -0
  32. data/lib/p4_web_api_client/models/server.rb +96 -0
  33. data/lib/p4_web_api_client/models/stream.rb +111 -0
  34. data/lib/p4_web_api_client/models/triggers.rb +34 -0
  35. data/lib/p4_web_api_client/models/user.rb +75 -0
  36. data/lib/p4_web_api_client/models.rb +14 -0
  37. data/lib/p4_web_api_client/version.rb +3 -0
  38. data/lib/p4_web_api_client.rb +6 -0
  39. data/spec/branches_spec.rb +63 -0
  40. data/spec/change_spec.rb +16 -0
  41. data/spec/clients_spec.rb +64 -0
  42. data/spec/depots_spec.rb +62 -0
  43. data/spec/files_spec.rb +36 -0
  44. data/spec/groups_spec.rb +63 -0
  45. data/spec/init.base/init_p4d.rb +52 -0
  46. data/spec/jobs_spec.rb +66 -0
  47. data/spec/labels_spec.rb +62 -0
  48. data/spec/lib/test_connections.rb +28 -0
  49. data/spec/protections_spec.rb +31 -0
  50. data/spec/run_input_spec.rb +23 -0
  51. data/spec/run_spec.rb +21 -0
  52. data/spec/servers_spec.rb +64 -0
  53. data/spec/streams_spec.rb +74 -0
  54. data/spec/triggers_spec.rb +22 -0
  55. data/spec/users_spec.rb +78 -0
  56. metadata +285 -0
@@ -0,0 +1,75 @@
1
+ # Copyright (c) 2014 Perforce Software, Inc. All rights reserved.
2
+
3
+ require 'time'
4
+
5
+ module P4WebApiClient
6
+ module Models
7
+ # Models the output of the Label specification.
8
+ #
9
+ # See also:
10
+ # - http://www.perforce.com/perforce/r14.2/manuals/cmdref/p4_label.html
11
+ # - http://www.perforce.com/perforce/r14.2/manuals/cmdref/p4_labels.html
12
+ class Label
13
+ # The label name and primary id
14
+ attr_accessor :label
15
+
16
+ # The label's owner, a Perforce login
17
+ attr_accessor :owner
18
+
19
+ # DateTime of when the label wa last modified
20
+ attr_accessor :update
21
+
22
+ # DateTime when the label was last accessed, by running p4 labelsync on
23
+ # the label, or otherwise referring to a file with the revision
24
+ # specifier `@label`
25
+ attr_accessor :access
26
+
27
+ # An optional description of the label's purpose
28
+ attr_accessor :description
29
+
30
+ # String of different options to control behavior.
31
+ attr_accessor :options
32
+
33
+ # An optional revision specification for an automatic label
34
+ attr_accessor :revision
35
+
36
+ # Array of depot file specifications that can be tagged with this label.
37
+ attr_accessor :view
38
+
39
+ # If set, restricts label usage to the named server
40
+ attr_accessor :server_id
41
+
42
+ def initialize(obj = {})
43
+ @label = obj['Label'] if obj.key?('Label')
44
+ @owner = obj['Owner'] if obj.key?('Owner')
45
+ @update = Time.at(obj['Update']).to_datetime if obj.key?('Update')
46
+ @access = Time.at(obj['Access']).to_datetime if obj.key?('Access')
47
+ @description = obj['Description'] if obj.key?('Description')
48
+ @options = obj['Options'] if obj.key?('Options')
49
+ @revision = obj['Revision'] if obj.key?('Revision')
50
+ @view = obj['View'].map(&:clone) if obj.key?('View')
51
+ @server_id = obj['ServerID'] if obj.key?('ServerID')
52
+
53
+ # If the user has defined symbols in the Ruby-ish API, then use that
54
+ # too, but we expect the data to be in the right format.
55
+ obj.each_key do |key|
56
+ accessor = "#{key}="
57
+ send(accessor, obj[key]) if self.respond_to?(accessor)
58
+ end
59
+ end
60
+
61
+ def to_internal_hash
62
+ hash = {
63
+ Label: @label
64
+ }
65
+ hash[:Owner] = @owner if @owner
66
+ hash[:Description] = @description if @description
67
+ hash[:Options] = @options if @options
68
+ hash[:Revision] = @revision if @revision
69
+ hash[:View] = @view if @view
70
+ hash[:ServerID] = @server_id if @server_id
71
+ hash
72
+ end
73
+ end
74
+ end
75
+ end
@@ -0,0 +1,34 @@
1
+ # Copyright (c) 2014 Perforce Software, Inc. All rights reserved.
2
+
3
+ module P4WebApiClient
4
+ module Models
5
+ # Models the output of the 'p4 protects' command.
6
+ #
7
+ # See also:
8
+ # - http://www.perforce.com/perforce/doc.current/manuals/p4sag/chapter.protections.html
9
+ # - http://www.perforce.com/perforce/r14.2/manuals/cmdref/p4_protects.html
10
+ class Protections
11
+ # An array of strings, each string representing a line of the protections
12
+ # table. Order of the array is significant.
13
+ attr_accessor :protections
14
+
15
+ def initialize(obj = {})
16
+ @protections = obj['Protections'] if obj.key?('Protections')
17
+ @protections = [] unless @protections
18
+
19
+ # If the user has defined symbols in the Ruby-ish API, then use that
20
+ # too, but we expect the data to be in the right format.
21
+ obj.each_key do |key|
22
+ accessor = "#{key}="
23
+ send(accessor, obj[key]) if self.respond_to?(accessor)
24
+ end
25
+ end
26
+
27
+ def to_internal_hash
28
+ {
29
+ Protections: @protections
30
+ }
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,96 @@
1
+ # Copyright (c) 2014 Perforce Software, Inc. All rights reserved.
2
+
3
+ require 'time'
4
+
5
+ module P4WebApiClient
6
+ module Models
7
+ # Server specifications in the system
8
+ #
9
+ # See also:
10
+ # - http://www.perforce.com/perforce/doc.current/manuals/cmdref/p4_server.html
11
+ # - http://www.perforce.com/perforce/doc.current/manuals/cmdref/p4_servers.html
12
+ class Server
13
+ # A unique ID for the server.
14
+ attr_accessor :server_id
15
+
16
+ # Server executable type: :server, :proxy, :broker
17
+ attr_accessor :type
18
+
19
+ # Services provided by this server, one of: :standard, :replica, :broker,
20
+ # :proxy, :commit_server, :edge_server, :forwarding_replica,
21
+ # :build_server, :P4AUTH, :P4CHANGE
22
+ attr_accessor :services
23
+
24
+ # The P4NAME associated with this server
25
+ attr_accessor :name
26
+
27
+ # The P4PORT associated with this server
28
+ attr_accessor :address
29
+
30
+ # Optional description
31
+ attr_accessor :description
32
+
33
+ # The service user that is used by the server.
34
+ attr_accessor :user
35
+
36
+ # For a replica server, this optional field can contain
37
+ # one or more patterns describing how active client
38
+ # workspace metadata is to be filtered. Active client
39
+ # workspace data includes have lists, working records,
40
+ # and pending resolves.
41
+ attr_accessor :client_data_filter
42
+
43
+ # For a replica server, this optional field can contain one
44
+ # or more patterns describing how submitted revision
45
+ # metadata is to be filtered. Submitted revision data
46
+ # includes revision records, integration records, label
47
+ # contents, and the files listed in submitted changelists.
48
+ attr_accessor :revision_data_filter
49
+
50
+ # For a replica server, this optional field can contain one or more
51
+ # patterns describing the policy for automatically scheduling the
52
+ # replication of file content. If this field is present, only those
53
+ # files described by the pattern are automatically transferred to the
54
+ # replica; other files will not be transferred until they are referenced
55
+ # by a replica command which needs the file content.
56
+ attr_accessor :archive_data_filter
57
+
58
+ def initialize(obj = {})
59
+ @server_id = obj['ServerID']
60
+ @type = obj['Type'].to_sym if obj.key?('Type')
61
+ @services = obj['Services'].to_sym if obj.key?('Services')
62
+ @name = obj['Name']
63
+ @address = obj['Address']
64
+ @description = obj['Description']
65
+ @user = obj['User']
66
+ @client_data_filter = obj['ClientDataFilter']
67
+ @revision_data_filter = obj['RevisionDataFilter']
68
+ @archive_data_filter = obj['ArchiveDataFilter']
69
+
70
+ # If the user has defined symbols in the Ruby-ish API, then use that
71
+ # too, but we expect the data to be in the right format.
72
+ obj.each_key do |key|
73
+ accessor = "#{key}="
74
+ send(accessor, obj[key]) if self.respond_to?(accessor)
75
+ end
76
+ end
77
+
78
+ def to_internal_hash
79
+ hash = {
80
+ ServerID: @server_id
81
+ }
82
+ hash[:Type] = @type.to_s if @type
83
+ hash[:Services] = @services if @services
84
+ hash[:Name] = @name if @name
85
+ hash[:Address] = @address if @address
86
+ hash[:Description] = @description if @description
87
+ hash[:User] = @user if @user
88
+ hash[:ClientDataFilter] = @client_data_filter if @client_data_filter
89
+ hash[:RevisionDataFilter] =
90
+ @revision_data_filter if @revision_data_filter
91
+ hash[:ArchiveDataFilter] = @archive_data_filter if @archive_data_filter
92
+ hash
93
+ end
94
+ end
95
+ end
96
+ end
@@ -0,0 +1,111 @@
1
+ # Copyright (c) 2014 Perforce Software, Inc. All rights reserved.
2
+
3
+ require 'time'
4
+
5
+ module P4WebApiClient
6
+ module Models
7
+ # Model of stream specifications in the Perforce server.
8
+ #
9
+ # See also:
10
+ # - http://www.perforce.com/perforce/doc.current/manuals/cmdref/p4_stream.html
11
+ # - http://www.perforce.com/perforce/doc.current/manuals/cmdref/p4_streams.html
12
+ class Stream
13
+ # The stream name, which is also it's depot path, in the form
14
+ # //[depot name]/[stream name].
15
+ attr_accessor :stream
16
+
17
+ # DateTime the spec was last modified.
18
+ attr_accessor :update
19
+
20
+ # DateTime the stream was last accessed by any p4 command.
21
+ attr_accessor :access
22
+
23
+ # Perforce user or group that owns the stream.
24
+ attr_accessor :owner
25
+
26
+ # Display name for the stream. This is modifiable.
27
+ attr_accessor :name
28
+
29
+ # The stream parent, or :none if the `type` is :mainline
30
+ attr_accessor :parent
31
+
32
+ # The stream's type determines the expected flow of change. Valid stream
33
+ # types are :mainline, :virtual, :development, and :release.
34
+ attr_accessor :type
35
+
36
+ # Description of the stream
37
+ attr_accessor :description
38
+
39
+ # Settings that configure stream behavior. This is a single string with
40
+ # different values, e.g. "locked all toparent fromparent":
41
+ #
42
+ # See also:
43
+ # - http://www.perforce.com/perforce/doc.current/manuals/cmdref/p4_stream.html
44
+ attr_accessor :options
45
+
46
+ # Array of path definitions.
47
+ #
48
+ # Paths define how files are incorporated into the stream structure.
49
+ # Specify paths using the following format:
50
+ #
51
+ # path_type view_path [depot_path]
52
+ #
53
+ # where path_type is a single keyword, view_path is a file path with no
54
+ # leading slashes, and the optional depot_path is a file path beginning
55
+ # with //.
56
+ #
57
+ # Default: `share ...`
58
+ #
59
+ # See also:
60
+ # - http://www.perforce.com/perforce/doc.current/manuals/cmdref/p4_stream.html
61
+ attr_accessor :paths
62
+
63
+ # Array of remap definitions.
64
+ #
65
+ # See also:
66
+ # - http://www.perforce.com/perforce/doc.current/manuals/cmdref/p4_stream.html
67
+ attr_accessor :remapped
68
+
69
+ # An array of path specifications that should be ignored in client views.
70
+ attr_accessor :ignored
71
+
72
+ def initialize(obj = {})
73
+ @stream = obj['Stream']
74
+ @update = Time.at(obj['Update']).to_datetime if obj.key?('Update')
75
+ @access = Time.at(obj['Access']).to_datetime if obj.key?('Access')
76
+ @owner = obj['Owner']
77
+ @name = obj['Name']
78
+ @parent = obj['Parent']
79
+ @type = obj['Type'].to_sym if obj.key?('Type')
80
+ @description = obj['Description']
81
+ @options = obj['Options']
82
+ @paths = obj['Paths'].map(&:clone) if obj.key?('Paths')
83
+ @remapped = obj['Remapped'].map(&:clone) if obj.key?('Remapped')
84
+ @ignored = obj['Ignored'].map(&:clone) if obj.key?('Ignored')
85
+
86
+ # If the user has defined symbols in the Ruby-ish API, then use that
87
+ # too, but we expect the data to be in the right format.
88
+ obj.each_key do |key|
89
+ accessor = "#{key}="
90
+ send(accessor, obj[key]) if self.respond_to?(accessor)
91
+ end
92
+ end
93
+
94
+ def to_internal_hash
95
+ hash = {
96
+ Stream: @stream
97
+ }
98
+ hash[:Owner] = @owner if @owner
99
+ hash[:Name] = @name if @name
100
+ hash[:Parent] = @parent if @parent
101
+ hash[:Type] = @type.to_s if @type
102
+ hash[:Description] = @description if @description
103
+ hash[:Options] = @options if @options
104
+ hash[:Paths] = @paths if @paths
105
+ hash[:Remapped] = @remapped if @remapped
106
+ hash[:Ignored] = @ignored if @ignored
107
+ hash
108
+ end
109
+ end
110
+ end
111
+ end
@@ -0,0 +1,34 @@
1
+ # Copyright (c) 2014 Perforce Software, Inc. All rights reserved.
2
+
3
+ module P4WebApiClient
4
+ module Models
5
+ # Represents output of the 'p4 triggers' command.
6
+ #
7
+ # See also:
8
+ # - http://www.perforce.com/perforce/doc.current/manuals/p4sag/chapter.scripting.html
9
+ # - http://www.perforce.com/perforce/r14.2/manuals/cmdref/p4_triggers.html
10
+ class Triggers
11
+ # An array of 'triggers' entries, each entry is a string
12
+ attr_accessor :triggers
13
+
14
+ def initialize(obj = {})
15
+ # Make sure the array a deep copy to avoid any potential confusion
16
+ @triggers = obj['Triggers'].map(&:clone) if obj.key?('Triggers')
17
+ @triggers = [] unless @triggers
18
+
19
+ # If the user has defined symbols in the Ruby-ish API, then use that
20
+ # too, but we expect the data to be in the right format.
21
+ obj.each_key do |key|
22
+ accessor = "#{key}="
23
+ send(accessor, obj[key]) if self.respond_to?(accessor)
24
+ end
25
+ end
26
+
27
+ def to_internal_hash
28
+ {
29
+ Triggers: @triggers
30
+ }
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,75 @@
1
+ # Copyright (c) 2014 Perforce Software, Inc. All rights reserved.
2
+
3
+ module P4WebApiClient
4
+ module Models
5
+ # Models of Perforce users.
6
+ #
7
+ # See http://www.perforce.com/perforce/r14.2/manuals/cmdref/p4_user.html
8
+ class User
9
+ # The Perforce login
10
+ attr_accessor :user
11
+
12
+ # The type of User: :standard, :operator, or :service
13
+ attr_accessor :type
14
+
15
+ # Note that the default user email is `user@client`
16
+ attr_accessor :email
17
+
18
+ # Either :perforce or :ldap, please refer to the 'p4 user' command
19
+ # reference for more details.
20
+ attr_accessor :auth_method
21
+
22
+ # DateTime of the last update
23
+ attr_accessor :update
24
+
25
+ # DateTime of the user last ran a command
26
+ attr_accessor :access
27
+
28
+ # The user's full name, may not be set
29
+ attr_accessor :full_name
30
+
31
+ # DateTime of the user's last password change. May not be set
32
+ attr_accessor :password_change
33
+
34
+ # This can be set via Ruby code, though we never return the value, as
35
+ # parsed from JSON, since the tagged output is generally just a bunch of
36
+ # asterixes.
37
+ attr_accessor :password
38
+
39
+ # Assumed to be the parsed json response from either GET /v1/users or
40
+ # GET /v1/users/[userId]
41
+ def initialize(obj = {})
42
+ @user = obj['User'] if obj.key?('User')
43
+ @type = obj['Type'].to_sym if obj.key?('Type')
44
+ @email = obj['Email'] if obj.key?('Email')
45
+ @auth_method = obj['AuthMethod'].to_sym if obj.key?('AuthMethod')
46
+ @update = Time.at(obj['Update']).to_datetime if obj.key?('Update')
47
+ @access = Time.at(obj['Access']).to_datetime if obj.key?('Access')
48
+ @full_name = obj['FullName'] if obj.key?('FullName')
49
+ @password_change = Time.at(obj['PasswordChange']).to_datetime \
50
+ if obj.key?('PasswordChange')
51
+
52
+ # If the user has defined symbols in the Ruby-ish API, then use that
53
+ # too, but we expect the data to be in the right format.
54
+ obj.each_key do |key|
55
+ accessor = "#{key}="
56
+ send(accessor, obj[key]) if self.respond_to?(accessor)
57
+ end
58
+ end
59
+
60
+ # Returns a subset of values valid for POST operations
61
+ def to_internal_hash
62
+ hash = {
63
+ User: user
64
+ }
65
+ hash[:FullName] = full_name if full_name
66
+ hash[:Type] = type if type
67
+ hash[:Email] = email if email
68
+ hash[:AuthMethod] = auth_method if auth_method
69
+ hash[:Password] = password if password
70
+
71
+ hash
72
+ end
73
+ end
74
+ end
75
+ end
@@ -0,0 +1,14 @@
1
+
2
+ require 'p4_web_api_client/models/branch'
3
+ require 'p4_web_api_client/models/change'
4
+ require 'p4_web_api_client/models/client'
5
+ require 'p4_web_api_client/models/depot'
6
+ require 'p4_web_api_client/models/dir'
7
+ require 'p4_web_api_client/models/file'
8
+ require 'p4_web_api_client/models/group'
9
+ require 'p4_web_api_client/models/label'
10
+ require 'p4_web_api_client/models/protections'
11
+ require 'p4_web_api_client/models/server'
12
+ require 'p4_web_api_client/models/stream'
13
+ require 'p4_web_api_client/models/triggers'
14
+ require 'p4_web_api_client/models/user'
@@ -0,0 +1,3 @@
1
+ module P4WebApiClient
2
+ VERSION = '2014.2.0.pre1'
3
+ end
@@ -0,0 +1,6 @@
1
+ # Copyright (c) 2014 Perforce Software, Inc. All rights reserved.
2
+ #
3
+ # p4_web_api_client.rb
4
+
5
+ require 'p4_web_api_client/connection'
6
+ require 'p4_web_api_client/client'
@@ -0,0 +1,63 @@
1
+ # Copyright (c) 2014 Perforce Software, Inc. All rights reserved.
2
+
3
+ require 'rspec'
4
+ require 'p4_web_api_client'
5
+ require 'test_connections'
6
+
7
+ RSpec.describe P4WebApiClient::Client, '#create_branch' do
8
+
9
+ it 'should create a new branch - and return it via #branches' do
10
+ client_as_jdoe do |c|
11
+ new_branch = P4WebApiClient::Models::Branch.new
12
+ new_branch.branch = 'new_branch'
13
+ new_branch.description = 'Something for the kids'
14
+ new_branch.view = ['//depot/dev/kids/... //depot/main/kids/...']
15
+
16
+ c.create_branch(new_branch)
17
+
18
+ branches = c.branches
19
+ expect(branches.map(&:branch)).to include('new_branch')
20
+ end
21
+ end
22
+ end
23
+
24
+ RSpec.describe P4WebApiClient::Client, '#branch' do
25
+
26
+ it 'should load a single branch created via #create_branch' do
27
+ client_as_jdoe do |c|
28
+ new_branch = c.branch('new_branch')
29
+
30
+ expect(new_branch.description.strip).to eq('Something for the kids')
31
+ expect(new_branch.view.length).to eq(1)
32
+ expected_view = '//depot/dev/kids/... //depot/main/kids/...'
33
+ expect(new_branch.view.first).to eq(expected_view)
34
+ end
35
+ end
36
+ end
37
+
38
+ RSpec.describe P4WebApiClient::Client, '#update_branch' do
39
+
40
+ it "'should be able to update the branch description'" do
41
+ client_as_jdoe do |c|
42
+ new_branch = c.branch('new_branch')
43
+ new_branch.description = 'updated'
44
+
45
+ c.update_branch(new_branch)
46
+
47
+ loaded = c.branch('new_branch')
48
+ expect(loaded.description.strip).to eq('updated')
49
+ end
50
+ end
51
+ end
52
+
53
+ RSpec.describe P4WebApiClient::Client, '#delete_branch' do
54
+
55
+ it "'should be able to delete a branch created via #create_branch'" do
56
+ client_as_jdoe do |c|
57
+ c.delete_branch('new_branch')
58
+
59
+ branches = c.branches
60
+ expect(branches.map(&:branch)).to_not include('new_branch')
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,16 @@
1
+ # Copyright (c) 2014 Perforce Software, Inc. All rights reserved.
2
+
3
+ require 'rspec'
4
+ require 'p4_web_api_client'
5
+ require 'test_connections'
6
+
7
+ RSpec.describe P4WebApiClient::Client, '#changes' do
8
+
9
+ it 'should list change 1' do
10
+ client_as_jdoe do |c|
11
+ changes = c.changes
12
+ expect(changes.length).to be >= 1
13
+ expect(changes.map(&:change)).to include('1')
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,64 @@
1
+ # Copyright (c) 2014 Perforce Software, Inc. All rights reserved.
2
+
3
+ require 'rspec'
4
+ require 'p4_web_api_client'
5
+ require 'test_connections'
6
+
7
+ RSpec.describe P4WebApiClient::Client, '#create_client' do
8
+
9
+ it 'should create a new client - and return it via #clients' do
10
+ client_as_jdoe do |c|
11
+ new_client = P4WebApiClient::Models::Client.new
12
+ new_client.client = 'new_client'
13
+ new_client.description = 'A client'
14
+ new_client.root = '/tmp/new_client'
15
+ new_client.view = ['//depot/dev/kids/... //new_client/dev/kids/...']
16
+
17
+ c.create_client(new_client)
18
+
19
+ clients = c.clients
20
+ expect(clients.map(&:client)).to include('new_client')
21
+ end
22
+ end
23
+ end
24
+
25
+ RSpec.describe P4WebApiClient::Client, '#client' do
26
+
27
+ it 'should load a single client created via #create_client' do
28
+ client_as_jdoe do |c|
29
+ new_client = c.client('new_client')
30
+
31
+ expect(new_client.description.strip).to eq('A client')
32
+ expect(new_client.view.length).to eq(1)
33
+ expected_view = '//depot/dev/kids/... //new_client/dev/kids/...'
34
+ expect(new_client.view.first).to eq(expected_view)
35
+ end
36
+ end
37
+ end
38
+
39
+ RSpec.describe P4WebApiClient::Client, '#update_client' do
40
+
41
+ it "'should be able to update the client description'" do
42
+ client_as_jdoe do |c|
43
+ new_client = c.client('new_client')
44
+ new_client.description = 'updated'
45
+
46
+ c.update_client(new_client)
47
+
48
+ loaded = c.client('new_client')
49
+ expect(loaded.description.strip).to eq('updated')
50
+ end
51
+ end
52
+ end
53
+
54
+ RSpec.describe P4WebApiClient::Client, '#delete_client' do
55
+
56
+ it "'should be able to delete a client created via #create_client'" do
57
+ client_as_jdoe do |c|
58
+ c.delete_client('new_client')
59
+
60
+ clients = c.clients
61
+ expect(clients.map(&:client)).to_not include('new_client')
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,62 @@
1
+ # Copyright (c) 2014 Perforce Software, Inc. All rights reserved.
2
+
3
+ require 'rspec'
4
+ require 'p4_web_api_client'
5
+
6
+ require 'test_connections'
7
+
8
+ RSpec.describe P4WebApiClient::Client, '#create_depot' do
9
+
10
+ it 'should create a new depot - and return it via #depots' do
11
+ client_as_jdoe do |c|
12
+ new_depot = P4WebApiClient::Models::Depot.new
13
+ new_depot.depot = 'new_depot'
14
+ new_depot.description = 'A depot'
15
+ new_depot.type = :local
16
+ new_depot.map = 'new_depot/...'
17
+
18
+ c.create_depot(new_depot)
19
+
20
+ depots = c.depots
21
+ expect(depots.map(&:depot)).to include('new_depot')
22
+ end
23
+ end
24
+ end
25
+
26
+ RSpec.describe P4WebApiClient::Client, '#depot' do
27
+
28
+ it 'should load a single depot created via #create_depot' do
29
+ client_as_jdoe do |c|
30
+ new_depot = c.depot('new_depot')
31
+
32
+ expect(new_depot.description.strip).to eq('A depot')
33
+ end
34
+ end
35
+ end
36
+
37
+ RSpec.describe P4WebApiClient::Client, '#update_depot' do
38
+
39
+ it "'should be able to update the depot description'" do
40
+ client_as_jdoe do |c|
41
+ new_depot = c.depot('new_depot')
42
+ new_depot.description = 'updated'
43
+
44
+ c.update_depot(new_depot)
45
+
46
+ loaded = c.depot('new_depot')
47
+ expect(loaded.description.strip).to eq('updated')
48
+ end
49
+ end
50
+ end
51
+
52
+ RSpec.describe P4WebApiClient::Client, '#delete_depot' do
53
+
54
+ it "'should be able to delete a depot created via #create_depot'" do
55
+ client_as_jdoe do |c|
56
+ c.delete_depot('new_depot')
57
+
58
+ depots = c.depots
59
+ expect(depots.map(&:depot)).to_not include('new_depot')
60
+ end
61
+ end
62
+ end