test_rail_integration 0.0.8.8 → 0.0.8.9
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 +4 -4
- data/.gitignore +3 -1
- data/lib/test_rail_integration/cli.rb +18 -8
- data/lib/test_rail_integration/generator/connection.rb +0 -22
- data/lib/test_rail_integration/generator/test_run.rb +17 -0
- data/lib/test_rail_integration/version.rb +1 -1
- data/spec/check_test_run_spec.rb +1 -1
- data/spec/cli_spec.rb +53 -49
- metadata +2 -2
- data/lib/test_rail_integration/generator/test_run_creation.rb +0 -49
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0651cb6aabdecfe9a50f505e029038dbbb2c4fcd
|
4
|
+
data.tar.gz: 5b9eea8b4cfd649b35477e3f6de116b3166133d5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8b8ceec7cb756c098a32303013da483be093a7933e772a77b052881593aec14df77c552bb5183f8012da590c46833d1398dc0d521fe0a4052d777dbb00038982
|
7
|
+
data.tar.gz: 22dd7beb287162d2be292622300934ef204d53119b768ad3823634b0db6beeef1d0255e0b7fe00e59b55597b901b6be0e22cee1ff71920ba36c57070e6dc4440
|
data/.gitignore
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'thor'
|
2
2
|
require_relative 'generator/project'
|
3
3
|
require_relative 'generator/project/check'
|
4
|
-
require_relative 'generator/
|
4
|
+
require_relative 'generator/test_run'
|
5
5
|
|
6
6
|
class CLI < Thor
|
7
7
|
include TestRail
|
@@ -21,20 +21,34 @@ class CLI < Thor
|
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
|
+
desc "create_test_run", "Create test run with name. Set test run name through --test_run_name parameter"
|
25
|
+
option :test_run_name
|
26
|
+
def create_test_run
|
27
|
+
test_run_name = options[:test_run_name]
|
28
|
+
if test_run_name
|
29
|
+
if test_run_name == ''
|
30
|
+
puts "Test_run_name parameter should not be empty"
|
31
|
+
else
|
32
|
+
test_run = TestRail::TestRun.create(test_run_name)
|
33
|
+
puts "You successfully created test run with id #{test_run.id}"
|
34
|
+
end
|
35
|
+
else
|
36
|
+
puts "You must set correct test run name through --test_run_name\n"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
24
40
|
desc "shoot", "Run Test Rail integration with \n
|
25
41
|
--test_run_id for run id,
|
26
42
|
optional:
|
27
43
|
--venture for describing venture,
|
28
44
|
--env for describing environment for run,
|
29
45
|
--showroom with showroom name where start tests,
|
30
|
-
--command with new command
|
31
|
-
--auto for creating test run automatically and push all information inside"
|
46
|
+
--command with new command"
|
32
47
|
option :test_run_id
|
33
48
|
option :venture
|
34
49
|
option :showroom
|
35
50
|
option :command
|
36
51
|
option :env
|
37
|
-
option :auto
|
38
52
|
def shoot
|
39
53
|
if options[:test_run_id]
|
40
54
|
run_id = options[:test_run_id]
|
@@ -53,10 +67,6 @@ class CLI < Thor
|
|
53
67
|
Connection.test_run_id = run_id
|
54
68
|
TestRailTools.write_test_run_id(run_id)
|
55
69
|
TestRailTools.execute_generated_command(run_id, environment_for_run, command)
|
56
|
-
elsif options[:auto]
|
57
|
-
run_id = TestRunCreation.initialize_test_run
|
58
|
-
environment_for_run = options[:venture], options[:env]
|
59
|
-
TestRailTools.execute_generated_command(run_id, environment_for_run)
|
60
70
|
else
|
61
71
|
puts "You must set correct test run id through --test_run_id"
|
62
72
|
end
|
@@ -126,27 +126,5 @@ module TestRail
|
|
126
126
|
client.send_post("update_run/#{run_id}", {name: new_name})
|
127
127
|
end
|
128
128
|
|
129
|
-
#
|
130
|
-
# Send request for creation test run with name
|
131
|
-
# ("add_run/3", {suite_id: 3, name "New test run", include_all: false, case_ids: C31, C32, C33}
|
132
|
-
#
|
133
|
-
def self.create_new_test_run_with_name
|
134
|
-
client.send_post("add_run/#{project_id}", {suite_id: test_suite_id, name: generate_test_run_name, include_all: false, case_ids: cases_with_types})
|
135
|
-
end
|
136
|
-
|
137
|
-
#
|
138
|
-
# Get all test runs for project
|
139
|
-
#
|
140
|
-
def self.get_test_runs
|
141
|
-
client.send_get("get_runs/#{project_id}")
|
142
|
-
end
|
143
|
-
|
144
|
-
#
|
145
|
-
# Generate name for test run with date
|
146
|
-
#
|
147
|
-
def self.generate_test_run_name
|
148
|
-
"Test run #{Time.now.strftime("%d/%m/%Y")}"
|
149
|
-
end
|
150
|
-
|
151
129
|
end
|
152
130
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module TestRail
|
2
|
+
|
3
|
+
class TestRun
|
4
|
+
|
5
|
+
attr_accessor :id
|
6
|
+
|
7
|
+
private
|
8
|
+
def initialize(result)
|
9
|
+
self.id = result["id"]
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.create(test_run_name)
|
13
|
+
command_result = TestRail::Connection.create_test_run_with_name(test_run_name)
|
14
|
+
TestRun.new(command_result)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/spec/check_test_run_spec.rb
CHANGED
@@ -39,7 +39,7 @@ describe 'Checking test run' do
|
|
39
39
|
|
40
40
|
before(:each) do
|
41
41
|
allow(TestRail::Connection).to receive(:cases_with_types).and_return([1011, 1213])
|
42
|
-
allow(TestRail::Connection).to receive(:get_test_results).and_return([{"status_id" => 1, :comment => "FTW"}, {"status_id" => 5, :comment => "Burn heretics"}])
|
42
|
+
allow(TestRail::Connection).to receive(:get_test_results).and_return([{"status_id" => 1, :comment => "FTW"}, {"status_id" => 5, :comment => "Burn heretics"}] )
|
43
43
|
allow(TestRail::Connection).to receive(:get_case_info).and_return({id: 1011, "title" => 'MLP'})
|
44
44
|
allow(TestRail::Connection).to receive(:commit_test_result).and_return([])
|
45
45
|
end
|
data/spec/cli_spec.rb
CHANGED
@@ -67,76 +67,87 @@ describe CLI do
|
|
67
67
|
|
68
68
|
end
|
69
69
|
|
70
|
-
context 'when executing
|
70
|
+
context 'when executing create_test_run command' do
|
71
|
+
|
72
|
+
context 'and not passing test_run_name parameter' do
|
73
|
+
|
74
|
+
it 'should see output message' do
|
75
|
+
result = capture(:stdout) { @subject.create_test_run }
|
76
|
+
expect(result).to eq("You must set correct test run name through --test_run_name\n")
|
77
|
+
end
|
78
|
+
|
79
|
+
it 'should not not call check_test_run_statuses method' do
|
80
|
+
expect(TestRail::Connection).not_to receive(:create_test_run_with_name)
|
81
|
+
@subject.create_test_run
|
82
|
+
end
|
71
83
|
|
72
|
-
before(:each) do
|
73
|
-
allow(TestRail::Connection).to receive(:test_run_name).and_return("AT id staging new")
|
74
|
-
allow(TestRail::Connection).to receive(:cases_id).and_return(["11", "22", "33"])
|
75
|
-
allow(TestRail::TestRailTools).to receive(:exec).and_return("Ok")
|
76
84
|
end
|
77
85
|
|
78
|
-
context 'and
|
86
|
+
context 'and passing test_run_name parameter' do
|
87
|
+
|
88
|
+
before(:all) do
|
89
|
+
@subject.options = {:test_run_name => 'test run name'}
|
90
|
+
end
|
79
91
|
|
80
92
|
before(:each) do
|
81
|
-
allow(TestRail::Connection).to receive(:
|
82
|
-
|
93
|
+
allow(TestRail::Connection).to receive(:create_test_run_with_name).and_return(
|
94
|
+
{"id" => "561"})
|
83
95
|
end
|
84
96
|
|
85
|
-
it 'should
|
86
|
-
expect(TestRail::
|
87
|
-
@subject.
|
97
|
+
it 'should execute command once' do
|
98
|
+
expect(TestRail::Connection).to receive(:create_test_run_with_name)
|
99
|
+
@subject.create_test_run
|
88
100
|
end
|
89
101
|
|
90
|
-
it 'should see output
|
91
|
-
result = capture(:stdout) { @subject.
|
92
|
-
expect(result).to eq("You
|
102
|
+
it 'should see created test run id in output' do
|
103
|
+
result = capture(:stdout) { @subject.create_test_run }
|
104
|
+
expect(result).to eq("You successfully created test run with id 561\n")
|
93
105
|
end
|
94
106
|
|
95
107
|
end
|
96
108
|
|
97
|
-
context 'and
|
109
|
+
context 'and passing empty test_run_name parameter' do
|
98
110
|
|
99
|
-
|
100
|
-
|
101
|
-
expect(result).to eq("You must set correct test run id through --test_run_id\n")
|
111
|
+
before(:all) do
|
112
|
+
@subject.options = {:test_run_name => ''}
|
102
113
|
end
|
103
114
|
|
104
115
|
it 'should not execute command once' do
|
105
|
-
expect(TestRail::
|
106
|
-
@subject.
|
116
|
+
expect(TestRail::Connection).not_to receive(:create_test_run_with_name)
|
117
|
+
@subject.create_test_run
|
107
118
|
end
|
108
119
|
|
120
|
+
it 'should see a output' do
|
121
|
+
result = capture(:stdout) { @subject.create_test_run }
|
122
|
+
expect(result).to eq("Test_run_name parameter should not be empty\n")
|
123
|
+
end
|
109
124
|
end
|
110
125
|
|
111
|
-
|
126
|
+
end
|
112
127
|
|
113
|
-
|
114
|
-
@subject.options[:auto] = ''
|
115
|
-
@subject.options[:venture] = 'vn'
|
116
|
-
@subject.options[:env] = 'live_test'
|
117
|
-
allow(TestRail::TestRunCreation).to receive(:check_presence_of_test_run).and_return(true)
|
118
|
-
allow(TestRail::TestRunCreation).to receive(:get_created_test_run_id).and_return("12345")
|
119
|
-
end
|
128
|
+
context 'when executing shoot cli command' do
|
120
129
|
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
130
|
+
before(:each) do
|
131
|
+
allow(TestRail::Connection).to receive(:test_run_name).and_return("AT id staging new")
|
132
|
+
allow(TestRail::Connection).to receive(:cases_id).and_return(["11", "22", "33"])
|
133
|
+
allow(TestRail::TestRailTools).to receive(:exec).and_return("Ok")
|
134
|
+
end
|
126
135
|
|
127
|
-
|
128
|
-
|
129
|
-
|
136
|
+
context 'and not passing test run id param' do
|
137
|
+
|
138
|
+
before(:each) do
|
139
|
+
allow(TestRail::Connection).to receive(:test_run_name).and_return("AT id staging new")
|
140
|
+
allow(TestRail::Connection).to receive(:cases_id).and_return(["11", "22", "33"])
|
130
141
|
end
|
131
142
|
|
132
|
-
it 'should
|
143
|
+
it 'should not execute command once' do
|
144
|
+
expect(TestRail::TestRailTools).not_to receive(:exec)
|
133
145
|
@subject.shoot
|
134
|
-
expect(YAML.load(File.open(TestRail::TestRailDataLoad::TEST_RAIL_FILE_CONFIG_PATH))[:test_run_id]).to eq(12345)
|
135
146
|
end
|
136
147
|
|
137
|
-
it 'should
|
138
|
-
|
139
|
-
|
148
|
+
it 'should see output ' do
|
149
|
+
result = capture(:stdout) { @subject.shoot }
|
150
|
+
expect(result).to eq("You must set correct test run id through --test_run_id\n")
|
140
151
|
end
|
141
152
|
|
142
153
|
end
|
@@ -269,11 +280,4 @@ describe CLI do
|
|
269
280
|
end
|
270
281
|
end
|
271
282
|
end
|
272
|
-
end
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
283
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: test_rail_integration
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.8.
|
4
|
+
version: 0.0.8.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kirikami
|
@@ -174,7 +174,7 @@ files:
|
|
174
174
|
- lib/test_rail_integration/generator/test_rail_data_load.rb
|
175
175
|
- lib/test_rail_integration/generator/test_rail_hooks.rb
|
176
176
|
- lib/test_rail_integration/generator/test_rail_tools.rb
|
177
|
-
- lib/test_rail_integration/generator/
|
177
|
+
- lib/test_rail_integration/generator/test_run.rb
|
178
178
|
- lib/test_rail_integration/generator/test_run_parameters.rb
|
179
179
|
- lib/test_rail_integration/version.rb
|
180
180
|
- spec/api_calls_spec.rb
|
@@ -1,49 +0,0 @@
|
|
1
|
-
require_relative 'test_rail_data_load'
|
2
|
-
require_relative 'connection'
|
3
|
-
require_relative 'test_run_parameters'
|
4
|
-
|
5
|
-
module TestRail
|
6
|
-
class TestRunCreation
|
7
|
-
|
8
|
-
#
|
9
|
-
# Get all test run names for project
|
10
|
-
#
|
11
|
-
def self.get_test_runs_names
|
12
|
-
test_runs = Connection.get_test_runs
|
13
|
-
test_runs_names = []
|
14
|
-
test_runs.each { |test_run| test_runs_names.push(test_run.fetch("name")) }
|
15
|
-
test_runs_names
|
16
|
-
end
|
17
|
-
|
18
|
-
#
|
19
|
-
# Get id for new test run that we created
|
20
|
-
#
|
21
|
-
def self.get_created_test_run_id
|
22
|
-
test_runs = Connection.get_test_runs
|
23
|
-
created_test_run_id = test_runs.map { |test_run|
|
24
|
-
test_run.fetch("id") if test_run.fetch("name").eql? Connection.generate_test_run_name
|
25
|
-
}
|
26
|
-
created_test_run_id.first
|
27
|
-
end
|
28
|
-
|
29
|
-
#
|
30
|
-
# Checking that test run already created
|
31
|
-
#
|
32
|
-
def self.check_presence_of_test_run
|
33
|
-
TestRunCreation.get_test_runs_names.include? Connection.generate_test_run_name
|
34
|
-
end
|
35
|
-
|
36
|
-
#
|
37
|
-
# Check and create test run
|
38
|
-
#
|
39
|
-
def self.initialize_test_run
|
40
|
-
unless TestRunCreation.check_presence_of_test_run
|
41
|
-
Connection.create_new_test_run_with_name
|
42
|
-
end
|
43
|
-
created_test_run_id = TestRunCreation.get_created_test_run_id
|
44
|
-
TestRailTools.write_test_run_id(created_test_run_id)
|
45
|
-
end
|
46
|
-
|
47
|
-
end
|
48
|
-
|
49
|
-
end
|