pact_broker 2.27.3 → 2.27.4

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: 8b120fc3afe15b42e4b97ca8eee39afe2f7f3070
4
- data.tar.gz: 00ba1080e2f72e2fe27ed72a4adda5819cc0149a
3
+ metadata.gz: d4636b4295346d4ca3722a84204382c69fcedf36
4
+ data.tar.gz: b0d2d464ad6e2faeb3d77b054b574a4a6afa88a5
5
5
  SHA512:
6
- metadata.gz: c98ee07fa57d47767ce6a17d4d158082a9dd4b966a38a308836e11347d2909e3782fab0758ab7ffd2e05eb6d8cbe8c4844debfef6d19da73f7ed7d5cd8194aa6
7
- data.tar.gz: 3b120a72072e2f5363ba35a3c3467fd41facb6fd26fb2cbe65e4c6d0a8c4448ac7eb8c7f8ea640881f5a32a99af2fe4c6f1b9a08c726188ce3d1492334c8687a
6
+ metadata.gz: bbaeb6db596dfc7b43427e193b645431dc94e529134db0fc1b5184beee4111c5ef80fd8f6d20e86a6ec1da44bd06ec4d4b4a8aafcd31f5bbc8c0ba57aaa9d2af
7
+ data.tar.gz: 5e3fd018f7283e8ee7c55ad47e59d003c6499ed11dfff2cd2496e0a77d82c2de0437897bc2208bb72df1d78b8c0be2db07c84a6e69ed5faf73b218f3ed5bdf6b
data/CHANGELOG.md CHANGED
@@ -1,3 +1,13 @@
1
+ <a name="v2.27.4"></a>
2
+ ### v2.27.4 (2018-11-15)
3
+
4
+
5
+ #### Bug Fixes
6
+
7
+ * handle race conditions when creating a pacticipant ([b3799670](/../../commit/b3799670))
8
+ * correct order of arguments for merging pacts ([f6cfb197](/../../commit/f6cfb197))
9
+
10
+
1
11
  <a name="v2.27.3"></a>
2
12
  ### v2.27.3 (2018-11-01)
3
13
 
@@ -42,7 +42,13 @@ module PactBroker
42
42
  end
43
43
 
44
44
  def create args
45
- PactBroker::Domain::Pacticipant.new(name: args[:name], repository_url: args[:repository_url]).save(raise_on_save_failure: true)
45
+ id = PactBroker::Domain::Pacticipant.dataset.insert_ignore.insert(
46
+ name: args[:name],
47
+ repository_url: args[:repository_url],
48
+ created_at: Sequel.datetime_class.now,
49
+ updated_at: Sequel.datetime_class.now
50
+ )
51
+ PactBroker::Domain::Pacticipant.find(id: id)
46
52
  end
47
53
 
48
54
  def pacticipant_names
@@ -59,7 +59,7 @@ module PactBroker
59
59
  consumer_version = version_repository.find_by_pacticipant_id_and_number_or_create consumer.id, params[:consumer_version_number]
60
60
  existing_pact = pact_repository.find_by_version_and_provider(consumer_version.id, provider.id)
61
61
 
62
- params.merge!(json_content: Merger.merge_pacts(params[:json_content], existing_pact.json_content))
62
+ params.merge!(json_content: Merger.merge_pacts(existing_pact.json_content, params[:json_content]))
63
63
 
64
64
  update_pact params, existing_pact
65
65
  end
@@ -1,3 +1,3 @@
1
1
  module PactBroker
2
- VERSION = '2.27.3'
2
+ VERSION = '2.27.4'
3
3
  end
@@ -29,7 +29,7 @@ describe "Merging a pact" do
29
29
  let(:merged_pact_content) { load_fixture('a_consumer-a_provider-merged.json') }
30
30
 
31
31
  before do
32
- TestDataBuilder.new.create_pact_with_hierarchy("A Consumer", "1.2.3", "A Provider", existing_pact_content).and_return(:pact)
32
+ TestDataBuilder.new.create_pact_with_hierarchy("A Consumer", "1.2.3", "A Provider", existing_pact_content)
33
33
  end
34
34
 
35
35
  it "returns a 200 Success" do
@@ -7,11 +7,11 @@
7
7
  },
8
8
  "interactions": [
9
9
  {
10
- "description" : "a request for something",
10
+ "description" : "another request for something",
11
11
  "providerState": null,
12
12
  "request": {
13
13
  "method": "get",
14
- "path" : "/something"
14
+ "path" : "/something_else"
15
15
  },
16
16
  "response": {
17
17
  "status": 200,
@@ -19,11 +19,11 @@
19
19
  }
20
20
  },
21
21
  {
22
- "description" : "another request for something",
22
+ "description" : "a request for something",
23
23
  "providerState": null,
24
24
  "request": {
25
25
  "method": "get",
26
- "path" : "/something_else"
26
+ "path" : "/something"
27
27
  },
28
28
  "response": {
29
29
  "status": 200,
@@ -5,6 +5,39 @@ require 'support/test_data_builder'
5
5
  module PactBroker
6
6
  module Pacticipants
7
7
  describe Repository do
8
+ describe "#create" do
9
+ let(:repository) { Repository.new }
10
+
11
+ subject { repository.create(name: "Foo") }
12
+
13
+ context "when the pacticipant does not already exist" do
14
+ before do
15
+ TestDataBuilder.new.create_pacticipant("Bar")
16
+ end
17
+
18
+ subject { repository.create(name: "Foo") }
19
+
20
+ it "returns the new pacticipant" do
21
+ expect(subject).to be_a(PactBroker::Domain::Pacticipant)
22
+ expect(subject.name).to eq "Foo"
23
+ end
24
+ end
25
+
26
+ context "when a race condition occurs and the pacticipant was already created by another request" do
27
+ before do
28
+ TestDataBuilder.new.create_pacticipant("Foo")
29
+ end
30
+
31
+ it "does not raise an error" do
32
+ subject
33
+ end
34
+
35
+ it "returns the existing pacticipant" do
36
+ expect(subject).to be_a(PactBroker::Domain::Pacticipant)
37
+ expect(subject.name).to eq "Foo"
38
+ end
39
+ end
40
+ end
8
41
 
9
42
  describe "#find" do
10
43
  before do
@@ -29,43 +29,40 @@ module PactBroker
29
29
  end
30
30
 
31
31
  describe "#merge" do
32
-
33
- before :each do
34
- @pact_to_merge = load_json_fixture('consumer-provider.json')
35
- end
32
+ let(:pact_to_merge) { load_json_fixture('consumer-provider.json') }
36
33
 
37
34
  it "merges two pacts" do
38
- @pact_to_merge["interactions"] << example_interaction
39
- result = merge_pacts(example_pact, @pact_to_merge)
35
+ pact_to_merge["interactions"] << example_interaction
36
+ result = merge_pacts(example_pact, pact_to_merge)
40
37
  expect(result["interactions"]).to match_array(example_pact["interactions"].push(example_interaction))
41
38
  end
42
39
 
43
40
  it "is idempotent" do
44
- @pact_to_merge["interactions"] << example_interaction
45
- first_result = merge_pacts(example_pact, @pact_to_merge)
46
- second_result = merge_pacts(first_result, @pact_to_merge)
41
+ pact_to_merge["interactions"] << example_interaction
42
+ first_result = merge_pacts(example_pact, pact_to_merge)
43
+ second_result = merge_pacts(first_result, pact_to_merge)
47
44
  expect(first_result).to contain_hash second_result
48
45
  end
49
46
 
50
47
  it "overwrites identical interactions" do
51
- @pact_to_merge["interactions"][0]["response"]["body"] = "changed!"
52
- result = merge_pacts(example_pact, @pact_to_merge)
48
+ pact_to_merge["interactions"][0]["response"]["body"] = "changed!"
49
+ result = merge_pacts(example_pact, pact_to_merge)
53
50
 
54
51
  expect(result["interactions"].length).to eq example_pact["interactions"].length
55
52
  expect(result["interactions"].first["response"]["body"]).to eq "changed!"
56
53
  end
57
54
 
58
55
  it "appends interactions with a different provider state" do
59
- @pact_to_merge["interactions"][0]["provider_state"] = "upside down"
56
+ pact_to_merge["interactions"][0]["provider_state"] = "upside down"
60
57
 
61
- result = merge_pacts(example_pact, @pact_to_merge)
58
+ result = merge_pacts(example_pact, pact_to_merge)
62
59
  expect(result["interactions"].length).to eq example_pact["interactions"].length + 1
63
60
  end
64
61
 
65
62
  it "appends interactions with a different description" do
66
- @pact_to_merge["interactions"][0]["description"] = "getting $$$"
63
+ pact_to_merge["interactions"][0]["description"] = "getting $$$"
67
64
 
68
- result = merge_pacts(example_pact, @pact_to_merge)
65
+ result = merge_pacts(example_pact, pact_to_merge)
69
66
  expect(result["interactions"].length).to eq example_pact["interactions"].length + 1
70
67
  end
71
68
 
@@ -78,59 +75,57 @@ module PactBroker
78
75
  end
79
76
 
80
77
  describe "#conflict?" do
81
- before :each do
82
- @pact_to_compare = load_json_fixture('consumer-provider.json')
83
- end
78
+ let(:pact_to_compare) { load_json_fixture('consumer-provider.json') }
84
79
 
85
80
  it "returns false if interactions have different descriptions" do
86
- @pact_to_compare["interactions"][0]["description"] = "something else"
81
+ pact_to_compare["interactions"][0]["description"] = "something else"
87
82
 
88
- expect(compare_pacts(example_pact, @pact_to_compare)).to eq false
83
+ expect(compare_pacts(example_pact, pact_to_compare)).to eq false
89
84
  end
90
85
 
91
86
  it "returns false if interactions have different provider states" do
92
- @pact_to_compare["interactions"][0]["provider_state"] = "some other thing"
93
- expect(compare_pacts(example_pact, @pact_to_compare)).to eq false
87
+ pact_to_compare["interactions"][0]["provider_state"] = "some other thing"
88
+ expect(compare_pacts(example_pact, pact_to_compare)).to eq false
94
89
  end
95
90
 
96
91
  context "when interactions have the same desc/state" do
97
92
  it "returns false if request parameters are the same" do
98
- expect(compare_pacts(example_pact, @pact_to_compare)).to eq false
93
+ expect(compare_pacts(example_pact, pact_to_compare)).to eq false
99
94
  end
100
95
 
101
96
  it "returns true if requests have a different query" do
102
- @pact_to_compare["interactions"][0]["request"]["query"] = "foo=bar&baz=qux"
103
- expect(compare_pacts(example_pact, @pact_to_compare)).to eq true
97
+ pact_to_compare["interactions"][0]["request"]["query"] = "foo=bar&baz=qux"
98
+ expect(compare_pacts(example_pact, pact_to_compare)).to eq true
104
99
  end
105
100
 
106
101
  it "returns true if requests have a different body" do
107
- @pact_to_compare["interactions"][0]["request"]["body"] = { "something" => { "nested" => "deeply" } }
108
- expect(compare_pacts(example_pact, @pact_to_compare)).to eq true
102
+ pact_to_compare["interactions"][0]["request"]["body"] = { "something" => { "nested" => "deeply" } }
103
+ expect(compare_pacts(example_pact, pact_to_compare)).to eq true
109
104
  end
110
105
 
111
106
  it "returns true if request method is different" do
112
- @pact_to_compare["interactions"][0]["request"]["method"] = "post"
113
- expect(compare_pacts(example_pact, @pact_to_compare)).to eq true
107
+ pact_to_compare["interactions"][0]["request"]["method"] = "post"
108
+ expect(compare_pacts(example_pact, pact_to_compare)).to eq true
114
109
  end
115
110
 
116
111
  it "returns true if request path is different" do
117
- @pact_to_compare["interactions"][0]["request"]["path"] = "/new_path"
118
- expect(compare_pacts(example_pact, @pact_to_compare)).to eq true
112
+ pact_to_compare["interactions"][0]["request"]["path"] = "/new_path"
113
+ expect(compare_pacts(example_pact, pact_to_compare)).to eq true
119
114
  end
120
115
 
121
116
  it "returns true if request headers are different" do
122
- @pact_to_compare["interactions"][0]["request"]["headers"]["Content-Type"] = "text/html"
123
- expect(compare_pacts(example_pact, @pact_to_compare)).to eq true
117
+ pact_to_compare["interactions"][0]["request"]["headers"]["Content-Type"] = "text/html"
118
+ expect(compare_pacts(example_pact, pact_to_compare)).to eq true
124
119
  end
125
120
 
126
121
  it "returns true if request has additional headers" do
127
- @pact_to_compare["interactions"][0]["request"]["headers"]["Accept"] = "text/html"
128
- expect(compare_pacts(example_pact, @pact_to_compare)).to eq true
122
+ pact_to_compare["interactions"][0]["request"]["headers"]["Accept"] = "text/html"
123
+ expect(compare_pacts(example_pact, pact_to_compare)).to eq true
129
124
  end
130
125
 
131
126
  it "returns true if request has missing headers" do
132
- @pact_to_compare["interactions"][0]["request"]["headers"].delete("Content-Type")
133
- expect(compare_pacts(example_pact, @pact_to_compare)).to eq true
127
+ pact_to_compare["interactions"][0]["request"]["headers"].delete("Content-Type")
128
+ expect(compare_pacts(example_pact, pact_to_compare)).to eq true
134
129
  end
135
130
  end
136
131
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pact_broker
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.27.3
4
+ version: 2.27.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bethany Skurrie
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2018-11-01 00:00:00.000000000 Z
13
+ date: 2018-11-15 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: httparty