test_rail_integration 0.0.9.1 → 0.0.9.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 358ef63f7961598a1e416d4b51df3b73b1c80b50
4
- data.tar.gz: 4c7f618f6398977f3b6095018ac569344789f834
3
+ metadata.gz: d6be0e981007474d44975ad766ef17025330fe2e
4
+ data.tar.gz: fbb645c2798102f90b0ac8c83e57e6b899d62ec0
5
5
  SHA512:
6
- metadata.gz: cbbda4abe090101224b3b8cef74355b4663d6a84aae974bd20cd458218c93eb644934e70184909d4bd27c266979a9725c9e7e65b3478b2b4f19cdde8153475b2
7
- data.tar.gz: 97eeab62fc159b2353b2a864c1fe2cb84ca2cb5770dc00412e5d9bfc85d8650c97d2865ee3511d8841ea9d6fbd1a12d75a2664705eed513f8a36c2b8d1e8af1c
6
+ metadata.gz: 8af6f8a8e1ec04bd87b420749b36db0460fc09415cb74b7654ba5e9043dee68ea4b2e9c1a625c3afefeef3327085773cfb6b3a8b57648d3440f93ae4334831b9
7
+ data.tar.gz: fbe01707a5abd6aacee25c06f6ab6d62bc7cc9e6d78edcf8bc4476c15091680b2c6e7aa3e65d5266a84460360cf8f43c2d935fb134d4bd4f11bccec421468c18
@@ -8,37 +8,43 @@ class CLI < Thor
8
8
  include TestRail
9
9
 
10
10
  desc "perform", "Creates project for interaction with TestRail"
11
+
11
12
  def perform
12
13
  TestRail::Generators::Project.copy_file("test_rail_data.yml", "config/data/")
13
14
  end
14
15
 
15
- desc "check_test_run_and_update", "Check test run statuses and update. Set test run id through --test_run_id parameter"
16
+ desc "check_test_run_and_update", "Check test run statuses and update. Set test run id through --test_run_id parameter, --build_url for adding build url to test run description"
16
17
  option :test_run_id
18
+ option :build_url
19
+
17
20
  def check_test_run_and_update
18
- if options[:test_run_id]
21
+ if options[:build_url] && options[:test_run_id]
22
+ TestRail::Connection.write_build_url(options[:test_run_id], options[:build_url])
23
+ elsif options[:test_run_id]
19
24
  TestRail::Check.check_test_run_statuses(options[:test_run_id])
20
25
  else
21
26
  puts "You must set correct test run id through --test_run_id"
22
27
  end
23
- end
28
+ end
24
29
 
25
- desc "create_test_run", "Create test run with name. Set test run name through --test_run_name parameter"
26
- option :test_run_name
27
- def create_test_run
28
- test_run_name = options[:test_run_name]
29
- if test_run_name
30
- if test_run_name == ''
31
- puts "Test_run_name parameter should not be empty"
32
- else
33
- test_run = TestRail::TestRun.create(test_run_name)
34
- puts "You successfully created test run with id #{test_run.id}"
35
- end
30
+ desc "create_test_run", "Create test run with name. Set test run name through --test_run_name parameter"
31
+ option :test_run_name
32
+
33
+ def create_test_run
34
+ test_run_name = options[:test_run_name]
35
+ if test_run_name
36
+ if test_run_name == ''
37
+ puts "Test_run_name parameter should not be empty"
36
38
  else
37
- puts "You must set correct test run name through --test_run_name\n"
39
+ test_run = TestRail::TestRun.create(test_run_name)
40
+ puts "You successfully created test run with id #{test_run.id}"
38
41
  end
42
+ else
43
+ puts "You must set correct test run name through --test_run_name\n"
39
44
  end
45
+ end
40
46
 
41
- desc "shoot", "Run Test Rail integration with \n
47
+ desc "shoot", "Run Test Rail integration with \n
42
48
  --test_run_id for run id,
43
49
  optional:
44
50
  --venture for describing venture,
@@ -48,78 +54,80 @@ class CLI < Thor
48
54
  --auto for getting env, venture params from test run name,
49
55
  --simple for run without venture and env params,
50
56
  --type to define tests with type to execute."
51
- option :test_run_id
52
- option :venture
53
- option :showroom
54
- option :command
55
- option :env
56
- option :auto
57
- option :simple
58
- option :type
59
- def shoot
60
- if options[:test_run_id]
61
- test_run_id = options[:test_run_id]
62
- Connection.test_run_id = test_run_id
63
- TestRailTools.write_test_run_id(test_run_id)
64
- command = TestRail::Command.new(test_run_id)
65
- if options[:auto]
66
- parameters = TestRail::TestRun.get_by_id(test_run_id).name.downcase.match(/(#{TestRunParameters::VENTURE_REGEX}) (#{TestRunParameters::ENVIRONMENT_REGEX})*/)
67
- if parameters.nil?
68
- puts "Your test run name is not correct. It don't contain venture, env params. Please provide correct name for test run on test rail side."
69
- return
70
- end
71
- if parameters[1].nil?
72
- puts "Your test run name is not correct. It don't contain venture param. Please provide correct name for test run on test rail side."
73
- return
74
- end
75
- if parameters[2].nil?
76
- puts "Your test run name is not correct. It don't contain env param. Please provide correct name for test run on test rail side."
77
- return
78
- end
79
- if parameters
80
- # TODO venture can be everything
81
- if options[:venture]
82
- command.venture = options[:venture]
83
- else
84
- command.venture = parameters[1]
85
- end
86
- command.env = parameters[2]
87
- end
88
- elsif options[:simple] && !options[:command]
89
- puts "You should add command param to execute simple execution"
57
+ option :test_run_id
58
+ option :venture
59
+ option :showroom
60
+ option :command
61
+ option :env
62
+ option :auto
63
+ option :simple
64
+ option :type
65
+
66
+ def shoot
67
+ if options[:test_run_id]
68
+ test_run_id = options[:test_run_id]
69
+ Connection.test_run_id = test_run_id
70
+ TestRailTools.write_test_run_id(test_run_id)
71
+ command = TestRail::Command.new(test_run_id)
72
+ if options[:auto]
73
+ parameters = TestRail::TestRun.get_by_id(test_run_id).name.downcase.match(/(#{TestRunParameters::VENTURE_REGEX}) (#{TestRunParameters::ENVIRONMENT_REGEX})*/)
74
+ if parameters.nil?
75
+ puts "Your test run name is not correct. It don't contain venture, env params. Please provide correct name for test run on test rail side."
90
76
  return
91
- elsif !options[:simple] && !options[:command]
92
- if options[:venture].nil? && options[:env].nil?
93
- puts "You must set correct env, venture params through --env, --venture in order to execute command"
94
- return
95
- end
96
- if options[:venture].nil?
97
- puts "You must set correct venture param through --venture in order to execute command"
98
- return
99
- end
100
- if options[:env].nil?
101
- puts "You must set correct env param through --env in order to execute command"
102
- return
77
+ end
78
+ if parameters[1].nil?
79
+ puts "Your test run name is not correct. It don't contain venture param. Please provide correct name for test run on test rail side."
80
+ return
81
+ end
82
+ if parameters[2].nil?
83
+ puts "Your test run name is not correct. It don't contain env param. Please provide correct name for test run on test rail side."
84
+ return
85
+ end
86
+ if parameters
87
+ # TODO venture can be everything
88
+ if options[:venture]
89
+ command.venture = options[:venture]
90
+ else
91
+ command.venture = parameters[1]
103
92
  end
104
- command.venture = options[:venture]
105
- command.env = options[:env]
93
+ command.env = parameters[2]
106
94
  end
107
- if options[:env] == "showroom" && options[:showroom]
108
- command.env = command.env + " SR='#{options[:showroom]}'"
95
+ elsif options[:simple] && !options[:command]
96
+ puts "You should add command param to execute simple execution"
97
+ return
98
+ elsif !options[:simple] && !options[:command]
99
+ if options[:venture].nil? && options[:env].nil?
100
+ puts "You must set correct env, venture params through --env, --venture in order to execute command"
101
+ return
109
102
  end
110
- if options[:command]
111
- command.command = options[:command]
112
- else
113
- command.command = TestRunParameters::EXEC_COMMAND
103
+ if options[:venture].nil?
104
+ puts "You must set correct venture param through --venture in order to execute command"
105
+ return
114
106
  end
115
- if options[:type]
116
- command.type = options[:type].to_i
107
+ if options[:env].nil?
108
+ puts "You must set correct env param through --env in order to execute command"
109
+ return
117
110
  end
118
- command.generate
119
- command.execute
111
+ command.venture = options[:venture]
112
+ command.env = options[:env]
113
+ end
114
+ if options[:env] == "showroom" && options[:showroom]
115
+ command.env = command.env + " SR='#{options[:showroom]}'"
116
+ end
117
+ if options[:command]
118
+ command.command = options[:command]
120
119
  else
121
- puts "You must set correct test run id through --test_run_id"
120
+ command.command = TestRunParameters::EXEC_COMMAND
122
121
  end
122
+ if options[:type]
123
+ command.type = options[:type].to_i
124
+ end
125
+ command.generate
126
+ command.execute
127
+ else
128
+ puts "You must set correct test run id through --test_run_id"
123
129
  end
124
130
  end
125
131
 
132
+ end
133
+
@@ -28,8 +28,7 @@ module TestRail
28
28
  end
29
29
 
30
30
  def get_tags
31
- cases = nil
32
- if type.nil?
31
+ if self.type.nil?
33
32
  cases = Connection.cases_ids_by_default(self.id)
34
33
  else
35
34
  cases = Connection.cases_ids_by_type(self.id, self.type)
@@ -121,6 +121,9 @@ module TestRail
121
121
  case_ids
122
122
  end
123
123
 
124
+ #
125
+ # Get info about test cases from TestRail
126
+ #
124
127
  def self.get_case_info(case_id)
125
128
  client.send_get("get_case/#{case_id}")
126
129
  end
@@ -135,5 +138,20 @@ module TestRail
135
138
  client.send_post("update_run/#{run_id}", {name: new_name})
136
139
  end
137
140
 
141
+ #
142
+ # Update test run with fields
143
+ #
144
+ def self.update_test_run(run_id, name_of_run = nil, description = nil, assigned_to_id = nil )
145
+ client.send_post("update_run/#{run_id}", {name: name_of_run, description: description, assignedto_id: assigned_to_id})
146
+ end
147
+
148
+ #
149
+ # Write TeamCity build id to TestRail
150
+ #
151
+ def self.write_build_url(test_run_id, build_id)
152
+ description = "Build url: #{build_id}"
153
+ update_test_run(test_run_id, nil, description, nil)
154
+ end
155
+
138
156
  end
139
157
  end
@@ -1,3 +1,3 @@
1
1
  module TestRailIntegration
2
- VERSION = "0.0.9.1"
2
+ VERSION = "0.0.9.2"
3
3
  end
@@ -64,6 +64,26 @@ describe CLI do
64
64
 
65
65
  end
66
66
 
67
+ context 'passing test run id and build url' do
68
+ before :each do
69
+ @subject.options = {:build_url => 'http://teamcity.ua/buildnum123', :test_run_id => 12345}
70
+ end
71
+
72
+ after :all do
73
+ @subject.options.clear
74
+ end
75
+
76
+ it 'should send update command' do
77
+ expect(TestRail::Connection).to receive(:write_build_url)
78
+ @subject.check_test_run_and_update
79
+ end
80
+
81
+ it 'should send data to Test Rail' do
82
+ expect(TestRail::Connection).to receive(:update_test_run).and_return("#{@subject.options[:test_run_id]}, nil, #{@subject.options[:build_url]}, nil")
83
+ @subject.check_test_run_and_update
84
+ end
85
+ end
86
+
67
87
  end
68
88
 
69
89
  context 'when executing create_test_run command' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: test_rail_integration
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9.1
4
+ version: 0.0.9.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kirikami
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-09 00:00:00.000000000 Z
11
+ date: 2016-01-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler