|
6 | 6 |
|
7 | 7 | describe "#load_vector_schema" do
|
8 | 8 | let(:vector_name) { "page" }
|
9 |
| - let(:vector_path) { "#{Dir.pwd}/vectors/page.yml" } |
| 9 | + let(:expected_schema) do |
| 10 | + { |
| 11 | + "name" => "page", |
| 12 | + "type" => "RECORD", |
| 13 | + "fields" => [ |
| 14 | + { "name" => "id", "type" => "STRING", "mode" => "NULLABLE" }, |
| 15 | + { "name" => "url", "type" => "STRING", "mode" => "NULLABLE" }, |
| 16 | + { "name" => "created_at", "type" => "TIMESTAMP", "mode" => "NULLABLE" } |
| 17 | + ] |
| 18 | + } |
| 19 | + end |
10 | 20 | let(:vector_config) do
|
11 | 21 | {
|
12 | 22 | "attributes" => {
|
|
18 | 28 | end
|
19 | 29 |
|
20 | 30 | before do
|
| 31 | + vector_path = File.join(Dir.pwd, "vectors", "#{vector_name}.yml") |
21 | 32 | allow(File).to receive(:exist?).with(vector_path).and_return(true)
|
22 | 33 | allow(YAML).to receive(:load_file).with(vector_path).and_return(vector_config)
|
23 | 34 | end
|
24 | 35 |
|
25 | 36 | it "loads and transforms vector schema" do
|
26 | 37 | schema = service.load_vector_schema(vector_name)
|
27 |
| - expect(schema).to eq( |
28 |
| - { |
29 |
| - "name" => "page", |
30 |
| - "type" => "RECORD", |
31 |
| - "fields" => [ |
32 |
| - { "name" => "id", "type" => "STRING", "mode" => "NULLABLE" }, |
33 |
| - { "name" => "url", "type" => "STRING", "mode" => "NULLABLE" }, |
34 |
| - { "name" => "created_at", "type" => "TIMESTAMP", "mode" => "NULLABLE" } |
35 |
| - ] |
36 |
| - } |
37 |
| - ) |
| 38 | + expect(schema).to eq(expected_schema) |
38 | 39 | end
|
39 | 40 |
|
40 | 41 | context "when vector file doesn't exist" do
|
41 | 42 | before do
|
| 43 | + vector_path = File.join(Dir.pwd, "vectors", "#{vector_name}.yml") |
42 | 44 | allow(File).to receive(:exist?).with(vector_path).and_return(false)
|
43 | 45 | allow(logger).to receive(:error)
|
44 | 46 | end
|
|
48 | 50 | end
|
49 | 51 |
|
50 | 52 | it "logs error" do
|
| 53 | + vector_path = File.join(Dir.pwd, "vectors", "#{vector_name}.yml") |
51 | 54 | service.load_vector_schema(vector_name)
|
52 | 55 | expect(logger).to have_received(:error)
|
53 | 56 | .with("Vector configuration not found: #{vector_path}")
|
|
0 commit comments