File: test_operations.rb

package info (click to toggle)
ruby-fog-google 1.19.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,568 kB
  • sloc: ruby: 16,775; makefile: 3
file content (45 lines) | stat: -rw-r--r-- 1,312 bytes parent folder | download | duplicates (4)
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
require "helpers/integration_test_helper"

class TestOperations < FogIntegrationTest
  def setup
    @subject = Fog::Compute[:google].operations
  end

  def test_all
    # TODO: what if this test runs first on a brand new project?
    assert_operator(@subject.all.size, :>=, 2,
                    "There should be at least 2 operations in the project")
  end

  def test_get
    @subject.all do |operation|
      refute_nil @subject.get(operation.name)
    end
  end

  def test_zone_scoped_all
    subject_list = @subject.all
    scoped_subject_list = @subject.all(zone: TEST_ZONE)

    # Assert that whatever .all(scope) returns is a subset of .all
    assert(scoped_subject_list.all? { |x| subject_list.include? x },
           "Output of @subject.all(zone:#{TEST_ZONE}) must be a subset of @subject.all")
  end

  def test_region_scoped_all
    subject_list = @subject.all
    scoped_subject_list = @subject.all(region: TEST_REGION)

    # Assert that whatever .all(scope) returns is a subset of .all
    assert(scoped_subject_list.all? { |x| subject_list.include? x },
           "Output of @subject.all(region:#{TEST_REGION}) must be a subset of @subject.all")
  end

  def test_bad_get
    assert_nil @subject.get("bad-name")
  end

  def test_enumerable
    assert_respond_to @subject, :each
  end
end