]>
Commit | Line | Data |
---|---|---|
1d09f67e TL |
1 | # Licensed to the Apache Software Foundation (ASF) under one |
2 | # or more contributor license agreements. See the NOTICE file | |
3 | # distributed with this work for additional information | |
4 | # regarding copyright ownership. The ASF licenses this file | |
5 | # to you under the Apache License, Version 2.0 (the | |
6 | # "License"); you may not use this file except in compliance | |
7 | # with the License. You may obtain a copy of the License at | |
8 | # | |
9 | # http://www.apache.org/licenses/LICENSE-2.0 | |
10 | # | |
11 | # Unless required by applicable law or agreed to in writing, | |
12 | # software distributed under the License is distributed on an | |
13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
14 | # KIND, either express or implied. See the License for the | |
15 | # specific language governing permissions and limitations | |
16 | # under the License. | |
17 | ||
18 | class TestFlightClient < Test::Unit::TestCase | |
19 | include Helper::Omittable | |
20 | ||
21 | def setup | |
22 | @server = nil | |
23 | omit("Arrow Flight is required") unless defined?(ArrowFlight) | |
24 | omit("Unstable on Windows") if Gem.win_platform? | |
25 | require_gi_bindings(3, 4, 7) | |
26 | @server = Helper::FlightServer.new | |
27 | host = "127.0.0.1" | |
28 | location = ArrowFlight::Location.new("grpc://#{host}:0") | |
29 | options = ArrowFlight::ServerOptions.new(location) | |
30 | @server.listen(options) | |
31 | @location = ArrowFlight::Location.new("grpc://#{host}:#{@server.port}") | |
32 | end | |
33 | ||
34 | def teardown | |
35 | return if @server.nil? | |
36 | @server.shutdown | |
37 | end | |
38 | ||
39 | def test_list_flights | |
40 | client = ArrowFlight::Client.new(@location) | |
41 | generator = Helper::FlightInfoGenerator.new | |
42 | assert_equal([generator.page_view], | |
43 | client.list_flights) | |
44 | end | |
45 | ||
46 | sub_test_case("#do_get") do | |
47 | def test_success | |
48 | client = ArrowFlight::Client.new(@location) | |
49 | info = client.list_flights.first | |
50 | endpoint = info.endpoints.first | |
51 | generator = Helper::FlightInfoGenerator.new | |
52 | reader = client.do_get(endpoint.ticket) | |
53 | assert_equal(generator.page_view_table, | |
54 | reader.read_all) | |
55 | end | |
56 | ||
57 | def test_error | |
58 | client = ArrowFlight::Client.new(@location) | |
59 | assert_raise(Arrow::Error::Invalid) do | |
60 | client.do_get(ArrowFlight::Ticket.new("invalid")) | |
61 | end | |
62 | end | |
63 | end | |
64 | end |