Skip to content

Commit 5504036

Browse files
committed
Add spec for default extra_headers
1 parent ddb63b5 commit 5504036

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

spec/openai/client/client_spec.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
before do
44
OpenAI.configure do |config|
55
config.organization_id = "organization_id0"
6+
config.extra_headers = { "test" => "X-Default" }
67
end
78
end
89

@@ -44,6 +45,7 @@
4445
expect(c0.send(:headers).values).to include(c0.organization_id)
4546
expect(c0.send(:conn).options.timeout).to eq(OpenAI::Configuration::DEFAULT_REQUEST_TIMEOUT)
4647
expect(c0.send(:uri, path: "")).to include(OpenAI::Configuration::DEFAULT_URI_BASE)
48+
expect(c0.send(:headers).values).to include("X-Default")
4749
expect(c0.send(:headers).values).not_to include("X-Test")
4850

4951
expect(c1.azure?).to eq(true)
@@ -54,6 +56,7 @@
5456
expect(c1.send(:headers).values).to include(c1.access_token)
5557
expect(c1.send(:conn).options.timeout).to eq(60)
5658
expect(c1.send(:uri, path: "")).to include("https://oai.hconeai.com/")
59+
expect(c1.send(:headers).values).not_to include("X-Default")
5760
expect(c1.send(:headers).values).to include("X-Test")
5861

5962
expect(c2.azure?).to eq(false)
@@ -65,6 +68,7 @@
6568
expect(c2.send(:headers).values).to include(c2.organization_id)
6669
expect(c2.send(:conn).options.timeout).to eq(1)
6770
expect(c2.send(:uri, path: "")).to include("https://example.com/")
71+
expect(c2.send(:headers).values).to include("X-Default")
6872
expect(c2.send(:headers).values).not_to include("X-Test")
6973
end
7074

0 commit comments

Comments
 (0)