Skip to content
This repository was archived by the owner on Jun 2, 2021. It is now read-only.

Commit d9b80a9

Browse files
Harsha NandiwadaMerricdeLauney
andcommitted
Add excluded files needed for 5ca3e89
[#173719526] Co-authored-by: Harsha Nandiwada <hnandiwada@vmware.com> Co-authored-by: Merric de Launey <mdelauney@pivotal.io>
1 parent 84758b0 commit d9b80a9

2 files changed

Lines changed: 90 additions & 0 deletions

File tree

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
require 'fetchers/base_list_fetcher'
2+
3+
module VCAP::CloudController
4+
class SidecarListFetcher < BaseListFetcher
5+
class << self
6+
def fetch_for_app(message, app_guid)
7+
app, _, _ = AppFetcher.new.fetch(app_guid)
8+
[app, filter(message, app.sidecars_dataset)]
9+
end
10+
11+
def fetch_for_process(message, process_guid)
12+
process, _, _ = ProcessFetcher.fetch(process_guid: process_guid)
13+
[process, filter(message, process.sidecars_dataset)]
14+
end
15+
16+
private
17+
18+
def filter(message, dataset)
19+
super(message, dataset, SidecarModel)
20+
end
21+
end
22+
end
23+
end
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
require 'spec_helper'
2+
require 'messages/sidecars_list_message'
3+
require 'fetchers/sidecar_list_fetcher'
4+
5+
module VCAP::CloudController
6+
RSpec.describe SidecarListFetcher do
7+
subject { SidecarListFetcher.fetch(message) }
8+
let(:fetcher) { SidecarListFetcher }
9+
let(:filters) { {} }
10+
let(:message) { SidecarsListMessage.from_params(filters) }
11+
let(:app_model) { AppModel.make }
12+
13+
describe '#fetch_for_app' do
14+
let!(:sidecar1) { SidecarModel.make(app: app_model) }
15+
let!(:sidecar2) { SidecarModel.make(app: app_model) }
16+
let!(:sidecar3) { SidecarModel.make(app: AppModel.make) }
17+
18+
it 'successfully loads sidecars' do
19+
app, results = fetcher.fetch_for_app(message, app_model.guid)
20+
21+
expect(app).to eq(app_model)
22+
expect(results).to contain_exactly(sidecar1, sidecar2)
23+
end
24+
end
25+
26+
describe '#fetch_for_process' do
27+
let!(:sidecar1a) { SidecarModel.make(app: app_model) }
28+
let!(:sidecar1b) { SidecarModel.make(app: app_model) }
29+
let!(:sidecar2) { SidecarModel.make(app: app_model) }
30+
31+
let!(:web_process) { ProcessModel.make(
32+
:process,
33+
app: app_model,
34+
type: 'web',
35+
command: 'rackup',
36+
)
37+
}
38+
let!(:worker_process) { ProcessModel.make(
39+
:process,
40+
app: app_model,
41+
type: 'worker',
42+
command: 'rackup',
43+
)
44+
}
45+
46+
before do
47+
SidecarProcessTypeModel.make(sidecar: sidecar1a, type: 'web')
48+
SidecarProcessTypeModel.make(sidecar: sidecar1b, type: 'web')
49+
SidecarProcessTypeModel.make(sidecar: sidecar2, type: 'worker')
50+
end
51+
52+
it 'successfully loads web sidecars' do
53+
process, results = fetcher.fetch_for_process(message, web_process.guid)
54+
55+
expect(process).to eq(web_process)
56+
expect(results).to contain_exactly(sidecar1a, sidecar1b)
57+
end
58+
59+
it 'successfully loads worker sidecars' do
60+
process, results = fetcher.fetch_for_process(message, worker_process.guid)
61+
62+
expect(process).to eq(worker_process)
63+
expect(results).to contain_exactly(sidecar2)
64+
end
65+
end
66+
end
67+
end

0 commit comments

Comments
 (0)