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.
- checksums.yaml +7 -0
- data/lib/p4_web_api_client/client/branches.rb +41 -0
- data/lib/p4_web_api_client/client/changes.rb +17 -0
- data/lib/p4_web_api_client/client/clients.rb +40 -0
- data/lib/p4_web_api_client/client/depots.rb +42 -0
- data/lib/p4_web_api_client/client/files.rb +30 -0
- data/lib/p4_web_api_client/client/groups.rb +41 -0
- data/lib/p4_web_api_client/client/jobs.rb +36 -0
- data/lib/p4_web_api_client/client/labels.rb +41 -0
- data/lib/p4_web_api_client/client/protections.rb +19 -0
- data/lib/p4_web_api_client/client/run.rb +38 -0
- data/lib/p4_web_api_client/client/servers.rb +38 -0
- data/lib/p4_web_api_client/client/streams.rb +38 -0
- data/lib/p4_web_api_client/client/triggers.rb +18 -0
- data/lib/p4_web_api_client/client/users.rb +38 -0
- data/lib/p4_web_api_client/client.rb +86 -0
- data/lib/p4_web_api_client/connection.rb +98 -0
- data/lib/p4_web_api_client/errors/perforce_problem.rb +25 -0
- data/lib/p4_web_api_client/errors/resource_not_found.rb +10 -0
- data/lib/p4_web_api_client/errors/server_error.rb +9 -0
- data/lib/p4_web_api_client/errors/unauthenticated.rb +11 -0
- data/lib/p4_web_api_client/errors.rb +4 -0
- data/lib/p4_web_api_client/models/branch.rb +66 -0
- data/lib/p4_web_api_client/models/change.rb +71 -0
- data/lib/p4_web_api_client/models/client.rb +129 -0
- data/lib/p4_web_api_client/models/depot.rb +97 -0
- data/lib/p4_web_api_client/models/dir.rb +45 -0
- data/lib/p4_web_api_client/models/file.rb +70 -0
- data/lib/p4_web_api_client/models/group.rb +102 -0
- data/lib/p4_web_api_client/models/label.rb +75 -0
- data/lib/p4_web_api_client/models/protections.rb +34 -0
- data/lib/p4_web_api_client/models/server.rb +96 -0
- data/lib/p4_web_api_client/models/stream.rb +111 -0
- data/lib/p4_web_api_client/models/triggers.rb +34 -0
- data/lib/p4_web_api_client/models/user.rb +75 -0
- data/lib/p4_web_api_client/models.rb +14 -0
- data/lib/p4_web_api_client/version.rb +3 -0
- data/lib/p4_web_api_client.rb +6 -0
- data/spec/branches_spec.rb +63 -0
- data/spec/change_spec.rb +16 -0
- data/spec/clients_spec.rb +64 -0
- data/spec/depots_spec.rb +62 -0
- data/spec/files_spec.rb +36 -0
- data/spec/groups_spec.rb +63 -0
- data/spec/init.base/init_p4d.rb +52 -0
- data/spec/jobs_spec.rb +66 -0
- data/spec/labels_spec.rb +62 -0
- data/spec/lib/test_connections.rb +28 -0
- data/spec/protections_spec.rb +31 -0
- data/spec/run_input_spec.rb +23 -0
- data/spec/run_spec.rb +21 -0
- data/spec/servers_spec.rb +64 -0
- data/spec/streams_spec.rb +74 -0
- data/spec/triggers_spec.rb +22 -0
- data/spec/users_spec.rb +78 -0
- metadata +285 -0
data/spec/files_spec.rb
ADDED
@@ -0,0 +1,36 @@
|
|
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, '#files' do
|
9
|
+
|
10
|
+
it 'should list the depots with no arguments' do
|
11
|
+
client_as_jdoe do |c|
|
12
|
+
depots = c.files
|
13
|
+
expect(depots.length).to be >= (1)
|
14
|
+
expect(depots.first.name).to eq('depot')
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should list 'dev' and 'main' dirs at the /depot path" do
|
19
|
+
client_as_jdoe do |c|
|
20
|
+
dirs = c.files('depot')
|
21
|
+
expect(dirs.length).to eq(2)
|
22
|
+
dir_names = dirs.map(&:name)
|
23
|
+
expect(dir_names).to include('dev')
|
24
|
+
expect(dir_names).to include('main')
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should list 'README' at the depot/dev/Experimental path" do
|
29
|
+
client_as_jdoe do |c|
|
30
|
+
paths = c.files('depot/dev/Experimental')
|
31
|
+
expect(paths.length).to eq(1)
|
32
|
+
names = paths.map(&:name)
|
33
|
+
expect(names).to include('README')
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
data/spec/groups_spec.rb
ADDED
@@ -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
|
+
|
6
|
+
require 'test_connections'
|
7
|
+
|
8
|
+
RSpec.describe P4WebApiClient::Client, '#create_group' do
|
9
|
+
|
10
|
+
it 'should create a new group - and return it via #groups' do
|
11
|
+
client_as_jdoe do |c|
|
12
|
+
new_group = P4WebApiClient::Models::Group.new
|
13
|
+
new_group.group = 'jarjar'
|
14
|
+
new_group.users = %w(mmustermann jdoe)
|
15
|
+
|
16
|
+
c.create_group(new_group)
|
17
|
+
|
18
|
+
groups = c.groups
|
19
|
+
jarjar = groups.find { |g| g.group == 'jarjar' }
|
20
|
+
expect(jarjar.users).to include('mmustermann')
|
21
|
+
expect(jarjar.users).to include('jdoe')
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
RSpec.describe P4WebApiClient::Client, '#group' do
|
27
|
+
|
28
|
+
it 'should load a single group created via #create_group' do
|
29
|
+
client_as_jdoe do |c|
|
30
|
+
jarjar = c.group('jarjar')
|
31
|
+
|
32
|
+
expect(jarjar.users).to include('mmustermann')
|
33
|
+
expect(jarjar.users).to include('jdoe')
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
RSpec.describe P4WebApiClient::Client, '#update_group' do
|
39
|
+
|
40
|
+
it "'should be able to add a group owner'" do
|
41
|
+
client_as_jdoe do |c|
|
42
|
+
jarjar = c.group('jarjar')
|
43
|
+
jarjar.owners << 'super'
|
44
|
+
|
45
|
+
c.update_group(jarjar)
|
46
|
+
|
47
|
+
loaded = c.group('jarjar')
|
48
|
+
expect(loaded.owners).to include('super')
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
RSpec.describe P4WebApiClient::Client, '#delete_group' do
|
54
|
+
|
55
|
+
it "'should be able to delete a group created via #create_group'" do
|
56
|
+
client_as_jdoe do |c|
|
57
|
+
c.delete_group('jarjar')
|
58
|
+
|
59
|
+
groups = c.groups
|
60
|
+
expect(groups.map(&:group)).to_not include('jarjar')
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
|
2
|
+
# This sets up a security=0 server but in Unicode mode, not sure about other
|
3
|
+
# 'recommended' settings
|
4
|
+
class BaseSystemSettings < SystemSettingsModel
|
5
|
+
@unicode = true
|
6
|
+
@security_level = 3
|
7
|
+
end
|
8
|
+
|
9
|
+
class SuperUser < UserModel
|
10
|
+
@super = true
|
11
|
+
@login = 'super'
|
12
|
+
@password = 'superuser1A!'
|
13
|
+
end
|
14
|
+
|
15
|
+
class MaxUser < UserModel
|
16
|
+
def rank
|
17
|
+
10
|
18
|
+
end
|
19
|
+
@login = 'mmustermann'
|
20
|
+
@full_name = 'Max Mustermann'
|
21
|
+
@password = 'mustermann1A!'
|
22
|
+
end
|
23
|
+
|
24
|
+
class JohnDoeUser < UserModel
|
25
|
+
def rank
|
26
|
+
11
|
27
|
+
end
|
28
|
+
@login = 'jdoe'
|
29
|
+
@full_name = 'John Doe'
|
30
|
+
@password = 'johndoe1A!'
|
31
|
+
end
|
32
|
+
|
33
|
+
class Changelist1 < ChangelistModel
|
34
|
+
def rank
|
35
|
+
1000
|
36
|
+
end
|
37
|
+
@description = 'A few basic adds'
|
38
|
+
@adds = [
|
39
|
+
FileDefinition.new(
|
40
|
+
path: 'depot/main/My Project/README',
|
41
|
+
content: <<-STOP.gsub(/^ {8}/, '')
|
42
|
+
This is the readme for My Project
|
43
|
+
STOP
|
44
|
+
),
|
45
|
+
FileDefinition.new(
|
46
|
+
path: 'depot/dev/Experimental/README',
|
47
|
+
content: <<-STOP.gsub(/^ {8}/, '')
|
48
|
+
This is an experimental project README.
|
49
|
+
STOP
|
50
|
+
)
|
51
|
+
]
|
52
|
+
end
|
data/spec/jobs_spec.rb
ADDED
@@ -0,0 +1,66 @@
|
|
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
|
+
first_job_id = nil
|
9
|
+
|
10
|
+
RSpec.describe P4WebApiClient::Client, '#create_job' do
|
11
|
+
|
12
|
+
it 'should create a new job - and return it via #jobs' do
|
13
|
+
client_as_jdoe do |c|
|
14
|
+
new_job = {
|
15
|
+
'User' => 'jdoe',
|
16
|
+
'Description' => 'Get to work!'
|
17
|
+
}
|
18
|
+
|
19
|
+
c.create_job(new_job)
|
20
|
+
|
21
|
+
jobs = c.jobs
|
22
|
+
expect(jobs.first['Description'].strip).to eq('Get to work!')
|
23
|
+
|
24
|
+
first_job_id = jobs.first['Job']
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
RSpec.describe P4WebApiClient::Client, '#job' do
|
30
|
+
|
31
|
+
it 'should load a single job created via #create_job' do
|
32
|
+
client_as_jdoe do |c|
|
33
|
+
loaded = c.job(first_job_id)
|
34
|
+
|
35
|
+
expect(loaded['Description'].strip).to eq('Get to work!')
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
RSpec.describe P4WebApiClient::Client, '#update_job' do
|
41
|
+
|
42
|
+
it "'should be able to change status'" do
|
43
|
+
client_as_jdoe do |c|
|
44
|
+
job = c.job(first_job_id)
|
45
|
+
|
46
|
+
job['Status'] = 'closed'
|
47
|
+
|
48
|
+
c.update_job(job)
|
49
|
+
|
50
|
+
loaded = c.job(first_job_id)
|
51
|
+
expect(loaded['Status']).to eq('closed')
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
RSpec.describe P4WebApiClient::Client, '#delete_job' do
|
57
|
+
|
58
|
+
it "'should be able to delete a job created via #create_job'" do
|
59
|
+
client_as_jdoe do |c|
|
60
|
+
c.delete_job(first_job_id)
|
61
|
+
|
62
|
+
jobs = c.jobs
|
63
|
+
expect(jobs.map { |b| b['Job'] }).to_not include(first_job_id)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
data/spec/labels_spec.rb
ADDED
@@ -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_label' do
|
9
|
+
|
10
|
+
it 'should create a new label - and return it via #labels' do
|
11
|
+
client_as_jdoe do |c|
|
12
|
+
new_label = P4WebApiClient::Models::Label.new
|
13
|
+
new_label.label = 'new_label'
|
14
|
+
new_label.description = 'A label'
|
15
|
+
new_label.view = ['//depot/...']
|
16
|
+
|
17
|
+
c.create_label(new_label)
|
18
|
+
|
19
|
+
labels = c.labels
|
20
|
+
expect(labels.map(&:label)).to include('new_label')
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
RSpec.describe P4WebApiClient::Client, '#label' do
|
26
|
+
|
27
|
+
it 'should load a single label created via #create_label' do
|
28
|
+
client_as_jdoe do |c|
|
29
|
+
new_label = c.label('new_label')
|
30
|
+
|
31
|
+
expect(new_label.description.strip).to eq('A label')
|
32
|
+
expect(new_label.view.first).to eq('//depot/...')
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
RSpec.describe P4WebApiClient::Client, '#update_label' do
|
38
|
+
|
39
|
+
it "'should be able to update the label description'" do
|
40
|
+
client_as_jdoe do |c|
|
41
|
+
new_label = c.label('new_label')
|
42
|
+
new_label.description = 'updated'
|
43
|
+
|
44
|
+
c.update_label(new_label)
|
45
|
+
|
46
|
+
loaded = c.label('new_label')
|
47
|
+
expect(loaded.description.strip).to eq('updated')
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
RSpec.describe P4WebApiClient::Client, '#delete_label' do
|
53
|
+
|
54
|
+
it "'should be able to delete a label created via #create_label'" do
|
55
|
+
client_as_jdoe do |c|
|
56
|
+
c.delete_label('new_label')
|
57
|
+
|
58
|
+
labels = c.labels
|
59
|
+
expect(labels.map(&:label)).to_not include('new_label')
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
|
2
|
+
require 'p4_web_api_client'
|
3
|
+
|
4
|
+
def client_as_jdoe
|
5
|
+
conn = P4WebApiClient::Connection.new(
|
6
|
+
url: 'http://localhost:4567/',
|
7
|
+
login: 'jdoe',
|
8
|
+
password: 'johndoe1A!',
|
9
|
+
prefix: '/v1'
|
10
|
+
)
|
11
|
+
client = P4WebApiClient::Client.open(conn)
|
12
|
+
yield client
|
13
|
+
ensure
|
14
|
+
client.close if client
|
15
|
+
end
|
16
|
+
|
17
|
+
def client_as_super
|
18
|
+
conn = P4WebApiClient::Connection.new(
|
19
|
+
url: 'http://localhost:4567/',
|
20
|
+
login: 'super',
|
21
|
+
password: 'superuser1A!',
|
22
|
+
prefix: '/v1'
|
23
|
+
)
|
24
|
+
client = P4WebApiClient::Client.open(conn)
|
25
|
+
yield client
|
26
|
+
ensure
|
27
|
+
client.close if client
|
28
|
+
end
|
@@ -0,0 +1,31 @@
|
|
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, '#protections' do
|
9
|
+
|
10
|
+
it 'should return an array with at least two protections' do
|
11
|
+
client_as_super do |c|
|
12
|
+
p = c.protections
|
13
|
+
expect(p.protections.length).to be >= 2
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
RSpec.describe P4WebApiClient::Client, '#update_protections' do
|
19
|
+
|
20
|
+
it 'should add a protections entry for the user jdoe' do
|
21
|
+
client_as_super do |c|
|
22
|
+
p = c.protections
|
23
|
+
p.protections << 'super user jdoe * //...'
|
24
|
+
|
25
|
+
c.update_protections(p)
|
26
|
+
|
27
|
+
loaded = c.protections
|
28
|
+
expect(loaded.protections).to include('super user jdoe * //...')
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# Copyright (c) 2014 Perforce Software, Inc. All rights reserved.
|
2
|
+
#
|
3
|
+
# run_input_spec.rb
|
4
|
+
|
5
|
+
require 'rspec'
|
6
|
+
require 'p4_web_api_client'
|
7
|
+
|
8
|
+
require 'test_connections'
|
9
|
+
|
10
|
+
RSpec.describe P4WebApiClient::Client, '#run_input' do
|
11
|
+
|
12
|
+
it "should allow us to run 'user -f joeuser' to create a new user" do
|
13
|
+
client_as_super do |c|
|
14
|
+
input = {
|
15
|
+
'User' => 'joeuser',
|
16
|
+
'FullName' => 'Joe User',
|
17
|
+
'Email' => 'joeuser@example.com'
|
18
|
+
}
|
19
|
+
results = c.run_input('user', input, ['-i', '-f'])
|
20
|
+
expect(results.length).to eq(1)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/spec/run_spec.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# Copyright (c) 2014 Perforce Software, Inc. All rights reserved.
|
2
|
+
#
|
3
|
+
# run_spec.rb
|
4
|
+
#
|
5
|
+
# Specifications for the P4WebApiClient::Client run method
|
6
|
+
|
7
|
+
require 'rspec'
|
8
|
+
require 'p4_web_api_client'
|
9
|
+
|
10
|
+
require 'test_connections'
|
11
|
+
|
12
|
+
RSpec.describe P4WebApiClient::Client, '#run' do
|
13
|
+
|
14
|
+
it "should allow us to run 'user -o' for our known user" do
|
15
|
+
client_as_super do |c|
|
16
|
+
results = c.run('user', ['-o'])
|
17
|
+
expect(results.length).to eq(1)
|
18
|
+
expect(results[0]['User']).to eq('super')
|
19
|
+
end
|
20
|
+
end
|
21
|
+
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
|
+
|
6
|
+
require 'test_connections'
|
7
|
+
|
8
|
+
RSpec.describe P4WebApiClient::Client, '#create_server' do
|
9
|
+
|
10
|
+
it 'should create a new server - and return it via #servers' do
|
11
|
+
client_as_jdoe do |c|
|
12
|
+
new_server = P4WebApiClient::Models::Server.new
|
13
|
+
new_server.server_id = 'new_server'
|
14
|
+
new_server.type = :server
|
15
|
+
new_server.description = 'A new server'
|
16
|
+
new_server.services = :standard
|
17
|
+
|
18
|
+
c.create_server(new_server)
|
19
|
+
|
20
|
+
servers = c.servers
|
21
|
+
expect(servers.map(&:server_id)).to include('new_server')
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
RSpec.describe P4WebApiClient::Client, '#server' do
|
27
|
+
|
28
|
+
it 'should load a single server created via #create_server' do
|
29
|
+
client_as_jdoe do |c|
|
30
|
+
new_server = c.server('new_server')
|
31
|
+
|
32
|
+
expect(new_server.description.strip).to eq('A new server')
|
33
|
+
expect(new_server.type).to eq(:server)
|
34
|
+
expect(new_server.services).to eq(:standard)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
RSpec.describe P4WebApiClient::Client, '#update_server' do
|
40
|
+
|
41
|
+
it "'should be able to update the server description'" do
|
42
|
+
client_as_jdoe do |c|
|
43
|
+
new_server = c.server('new_server')
|
44
|
+
new_server.description = 'updated'
|
45
|
+
|
46
|
+
c.update_server(new_server)
|
47
|
+
|
48
|
+
loaded = c.server('new_server')
|
49
|
+
expect(loaded.description.strip).to eq('updated')
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
RSpec.describe P4WebApiClient::Client, '#delete_server' do
|
55
|
+
|
56
|
+
it "'should be able to delete a server created via #create_server'" do
|
57
|
+
client_as_jdoe do |c|
|
58
|
+
c.delete_server('new_server')
|
59
|
+
|
60
|
+
servers = c.servers
|
61
|
+
expect(servers.map(&:server_id)).to_not include('new_server')
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,74 @@
|
|
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_stream' do
|
9
|
+
|
10
|
+
it 'should create a new stream - and return it via #streams' do
|
11
|
+
client_as_jdoe do |c|
|
12
|
+
new_depot = P4WebApiClient::Models::Depot.new
|
13
|
+
new_depot.depot = 'stuffs'
|
14
|
+
new_depot.type = :stream
|
15
|
+
new_depot.map = 'stuffs/...'
|
16
|
+
|
17
|
+
c.create_depot(new_depot)
|
18
|
+
|
19
|
+
new_stream = P4WebApiClient::Models::Stream.new
|
20
|
+
new_stream.stream = '//stuffs/new_stream'
|
21
|
+
new_stream.name = 'new_stream'
|
22
|
+
new_stream.description = 'A new stream'
|
23
|
+
new_stream.type = :mainline
|
24
|
+
new_stream.parent = 'none'
|
25
|
+
new_stream.paths = ['share ...']
|
26
|
+
new_stream.owner = 'jdoe'
|
27
|
+
|
28
|
+
c.create_stream(new_stream)
|
29
|
+
|
30
|
+
streams = c.streams
|
31
|
+
expect(streams.map(&:stream)).to include('//stuffs/new_stream')
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
RSpec.describe P4WebApiClient::Client, '#stream' do
|
37
|
+
|
38
|
+
it 'should load a single stream created via #create_stream' do
|
39
|
+
client_as_jdoe do |c|
|
40
|
+
new_stream = c.stream('//stuffs/new_stream')
|
41
|
+
|
42
|
+
expect(new_stream.description.strip).to eq('A new stream')
|
43
|
+
expect(new_stream.name).to eq('new_stream')
|
44
|
+
expect(new_stream.type).to eq(:mainline)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
RSpec.describe P4WebApiClient::Client, '#update_stream' do
|
50
|
+
|
51
|
+
it "'should be able to update the stream description'" do
|
52
|
+
client_as_jdoe do |c|
|
53
|
+
new_stream = c.stream('//stuffs/new_stream')
|
54
|
+
new_stream.description = 'updated'
|
55
|
+
|
56
|
+
c.update_stream(new_stream)
|
57
|
+
|
58
|
+
loaded = c.stream('//stuffs/new_stream')
|
59
|
+
expect(loaded.description.strip).to eq('updated')
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
RSpec.describe P4WebApiClient::Client, '#delete_stream' do
|
65
|
+
|
66
|
+
it "'should be able to delete a stream created via #create_stream'" do
|
67
|
+
client_as_jdoe do |c|
|
68
|
+
c.delete_stream('//stuffs/new_stream')
|
69
|
+
|
70
|
+
streams = c.streams
|
71
|
+
expect(streams.map(&:stream_id)).to_not include('//stuffs/new_stream')
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,22 @@
|
|
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, '#triggers' do
|
9
|
+
|
10
|
+
it 'should allow us to update and fetch a new example trigger line' do
|
11
|
+
client_as_super do |c|
|
12
|
+
t = c.triggers
|
13
|
+
t.triggers << 'cscheck change-submit //depot/... "cmd %changelist%"'
|
14
|
+
c.update_triggers(t)
|
15
|
+
|
16
|
+
loaded = c.triggers
|
17
|
+
expected_trigger = 'cscheck change-submit //depot/... "cmd %changelist%"'
|
18
|
+
expect(loaded.triggers).to include(expected_trigger)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
data/spec/users_spec.rb
ADDED
@@ -0,0 +1,78 @@
|
|
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, '#users' do
|
9
|
+
|
10
|
+
it "should at least return the 'jdoe' and 'super' users" do
|
11
|
+
client_as_jdoe do |c|
|
12
|
+
users = c.users
|
13
|
+
expect(users.length).to be >= 2
|
14
|
+
logins = users.map(&:user)
|
15
|
+
expect(logins).to include('jdoe')
|
16
|
+
expect(logins).to include('super')
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
RSpec.describe P4WebApiClient::Client, '#user' do
|
22
|
+
|
23
|
+
it "should return the user 'mmustermann' who has the name 'Max Mustermann'" do
|
24
|
+
client_as_jdoe do |c|
|
25
|
+
max = c.user('mmustermann')
|
26
|
+
expect(max.full_name).to eq('Max Mustermann')
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
RSpec.describe P4WebApiClient::Client, '#create_user' do
|
32
|
+
|
33
|
+
it 'should be able to create a new user and load it' do
|
34
|
+
client_as_jdoe do |c|
|
35
|
+
new_user = P4WebApiClient::Models::User.new
|
36
|
+
new_user.user = 'newuser'
|
37
|
+
new_user.full_name = 'New User'
|
38
|
+
new_user.email = 'newuser@example.com'
|
39
|
+
|
40
|
+
c.create_user(new_user)
|
41
|
+
|
42
|
+
loaded = c.user('newuser')
|
43
|
+
|
44
|
+
expect(loaded.user).to eq('newuser')
|
45
|
+
expect(loaded.full_name).to eq('New User')
|
46
|
+
expect(loaded.email).to eq('newuser@example.com')
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
RSpec.describe P4WebApiClient::Client, '#update_user' do
|
52
|
+
|
53
|
+
it "should be able update mmusterman's email to max_power@example.com" do
|
54
|
+
client_as_jdoe do |c|
|
55
|
+
max_user = c.user('mmustermann')
|
56
|
+
max_user.email = 'max_power@example.com'
|
57
|
+
|
58
|
+
c.update_user(max_user)
|
59
|
+
|
60
|
+
loaded = c.user('mmustermann')
|
61
|
+
|
62
|
+
expect(loaded.email).to eq('max_power@example.com')
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
# I *think* this will run after the create_user spec if defined here.
|
68
|
+
RSpec.describe P4WebApiClient::Client, '#delete_user' do
|
69
|
+
|
70
|
+
it 'should be able to delete the newuser user' do
|
71
|
+
client_as_jdoe do |c|
|
72
|
+
c.delete_user('newuser')
|
73
|
+
|
74
|
+
users = c.users
|
75
|
+
expect(users.find { |u| u.user == 'newuser' }).to be nil
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|