|
20 | 20 | Kubernetes::Watch.new(nil) |
21 | 21 | end |
22 | 22 |
|
| 23 | + it 'should connect correctly with resource version' do |
| 24 | + config = Kubernetes::Configuration.new |
| 25 | + config.scheme = 'http' |
| 26 | + config.host = 'k8s.io:8080' |
| 27 | + client = Kubernetes::ApiClient.new(config) |
| 28 | + |
| 29 | + WebMock.stub_request(:get, "http://k8s.io:8080/some/path?watch=true&resourceVersion=foo"). |
| 30 | + with( |
| 31 | + headers: { |
| 32 | + 'Authorization'=>'', |
| 33 | + 'Content-Type'=>'application/json', |
| 34 | + 'Expect'=>'', |
| 35 | + 'User-Agent'=>'Swagger-Codegen/1.0.0-alpha2/ruby' |
| 36 | + }). |
| 37 | + to_return(status: 200, body: "{}\n", headers: {}) |
| 38 | + |
| 39 | + watch = Kubernetes::Watch.new(client) |
| 40 | + result = [] |
| 41 | + watch.connect('/some/path', 'foo') do |obj| |
| 42 | + result << obj |
| 43 | + end |
| 44 | + end |
| 45 | + |
| 46 | + |
| 47 | + it 'should connect correctly' do |
| 48 | + config = Kubernetes::Configuration.new |
| 49 | + config.scheme = 'http' |
| 50 | + config.host = 'k8s.io:8080' |
| 51 | + client = Kubernetes::ApiClient.new(config) |
| 52 | + |
| 53 | + WebMock.stub_request(:get, "http://k8s.io:8080/some/path?watch=true"). |
| 54 | + with( |
| 55 | + headers: { |
| 56 | + 'Authorization'=>'', |
| 57 | + 'Content-Type'=>'application/json', |
| 58 | + 'Expect'=>'', |
| 59 | + 'User-Agent'=>'Swagger-Codegen/1.0.0-alpha2/ruby' |
| 60 | + }). |
| 61 | + to_return(status: 200, body: "{ \"foo\": \"bar\" }\n{ \"baz\": \"blah\" }\n{}\n", headers: {}) |
| 62 | + |
| 63 | + watch = Kubernetes::Watch.new(client) |
| 64 | + result = [] |
| 65 | + watch.connect('/some/path', nil) do |obj| |
| 66 | + result << obj |
| 67 | + end |
| 68 | + |
| 69 | + expect(result.length).to eq(3) |
| 70 | + expect(result[0]['foo']).to eq('bar') |
| 71 | + expect(result[1]['baz']).to eq('blah') |
| 72 | + end |
| 73 | + |
23 | 74 | it 'should parse chunks correctly' do |
24 | 75 | client = Kubernetes::Watch.new(nil) |
25 | 76 | last = '' |
|
0 commit comments