File: test_persistent_volume_claim.rb

package info (click to toggle)
ruby-kubeclient 4.13.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,112 kB
  • sloc: ruby: 4,225; makefile: 6
file content (30 lines) | stat: -rw-r--r-- 938 bytes parent folder | download
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
# frozen_string_literal: true

require_relative 'test_helper'

# PersistentVolumeClaim tests
class TestPersistentVolumeClaim < Minitest::Test
  def test_get_from_json_v1
    stub_core_api_list
    stub_request(:get, %r{/persistentvolumeclaims})
      .to_return(body: open_test_file('persistent_volume_claim.json'), status: 200)
    client = Kubeclient::Client.new('http://localhost:8080/api/', 'v1')
    claim = client.get_persistent_volume_claim('myclaim-1', 'default')

    assert_instance_of(Kubeclient::Resource, claim)
    assert_equal('myclaim-1', claim.metadata.name)
    assert_equal('3Gi', claim.spec.resources.requests.storage)
    assert_equal('pv0001', claim.spec.volumeName)

    assert_requested(
      :get,
      'http://localhost:8080/api/v1',
      times: 1
    )
    assert_requested(
      :get,
      'http://localhost:8080/api/v1/namespaces/default/persistentvolumeclaims/myclaim-1',
      times: 1
    )
  end
end