-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapp_connections_spec.rb
More file actions
168 lines (148 loc) · 4.46 KB
/
app_connections_spec.rb
File metadata and controls
168 lines (148 loc) · 4.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
# frozen_string_literal: true
require_relative "../lib/embed_workflow"
require "net/http"
describe "app_connections" do
before do
allow_any_instance_of(EmbedWorkflow::Client)
.to receive(:execute_request)
.with(instance_of(Net::HTTPRequest))
.and_return("response")
end
describe "#list" do
before do
allow_any_instance_of(EmbedWorkflow::Client)
.to receive(:get_request)
.with({ path: "/api/v1/app_connections", params: {} })
.and_return("response")
end
it "sends the correct parameters to the app_connections API" do
EmbedWorkflow::AppConnections.list
end
context "with pagination parameters" do
before do
allow_any_instance_of(EmbedWorkflow::Client)
.to receive(:get_request)
.with({
path: "/api/v1/app_connections",
params: {
starting_after: "550e8400-e29b-41d4-a716-446655440000",
limit: 50
}
})
.and_return("response")
end
it "sends the correct pagination parameters" do
EmbedWorkflow::AppConnections.list(
starting_after: "550e8400-e29b-41d4-a716-446655440000",
limit: 50
)
end
end
context "with user_key parameter" do
before do
allow_any_instance_of(EmbedWorkflow::Client)
.to receive(:get_request)
.with({
path: "/api/v1/app_connections",
params: { user_key: "api-user-1" }
})
.and_return("response")
end
it "sends the correct user_key parameter" do
EmbedWorkflow::AppConnections.list(user_key: "api-user-1")
end
end
end
describe "#fetch" do
before do
allow_any_instance_of(EmbedWorkflow::Client)
.to receive(:get_request)
.with({
path: "/api/v1/app_connections/75233470-6316-4fa9-a7f5-5196f3d06067",
params: {}
})
.and_return("response")
end
it "sends the correct parameters to the app_connections API" do
EmbedWorkflow::AppConnections.fetch(id: "75233470-6316-4fa9-a7f5-5196f3d06067")
end
context "with user_key parameter" do
before do
allow_any_instance_of(EmbedWorkflow::Client)
.to receive(:get_request)
.with({
path: "/api/v1/app_connections/75233470-6316-4fa9-a7f5-5196f3d06067",
params: { user_key: "api-user-1" }
})
.and_return("response")
end
it "sends the correct user_key parameter" do
EmbedWorkflow::AppConnections.fetch(
id: "75233470-6316-4fa9-a7f5-5196f3d06067",
user_key: "api-user-1"
)
end
end
end
describe "#create" do
before do
config = {
api_key: "sk-1234567890abcdef",
organization_id: "org-abcdefg123456"
}
allow_any_instance_of(EmbedWorkflow::Client)
.to receive(:post_request)
.with({
path: "/api/v1/app_connections",
body: {
name: "My OpenAI Connection",
app_type: "openai",
config: config
}
})
.and_return("response")
end
it "sends the correct parameters to the app_connections API" do
config = {
api_key: "sk-1234567890abcdef",
organization_id: "org-abcdefg123456"
}
EmbedWorkflow::AppConnections.create(
name: "My OpenAI Connection",
app_type: "openai",
config: config
)
end
end
describe "#update" do
before do
allow_any_instance_of(EmbedWorkflow::Client)
.to receive(:put_request)
.with({
path: "/api/v1/app_connections/75233470-6316-4fa9-a7f5-5196f3d06067",
body: { name: "Updated OpenAI Connection" }
})
.and_return("response")
end
it "sends the correct parameters to the app_connections API" do
EmbedWorkflow::AppConnections.update(
id: "75233470-6316-4fa9-a7f5-5196f3d06067",
name: "Updated OpenAI Connection"
)
end
end
describe "#delete" do
before do
allow_any_instance_of(EmbedWorkflow::Client)
.to receive(:delete_request)
.with({
path: "/api/v1/app_connections/75233470-6316-4fa9-a7f5-5196f3d06067",
params: {}
})
.and_return("response")
end
it "sends the correct parameters to the app_connections API" do
EmbedWorkflow::AppConnections.delete(id: "75233470-6316-4fa9-a7f5-5196f3d06067")
end
end
end