Sha256: c502b708f25d9780b659514cb741c0f53ca5c0a326da80ae320cc2bce78d7f9b

Contents?: true

Size: 1.23 KB

Versions: 25

Compression:

Stored size: 1.23 KB

Contents

require 'kontena/cli/nodes/label_command'
require 'kontena/cli/nodes/labels/remove_command'

describe Kontena::Cli::Nodes::Labels::RemoveCommand do
  include ClientHelpers
  include OutputHelpers

  before do
    allow(client).to receive(:get).with('nodes/test-grid/node').and_return(node)
  end

  context "for a node without any labels" do
    let :node do
      {
        "id" => 'test-grid/node',
        "name" => "node",
        "labels" => [],
      }
    end

    it "doesn't remove anything" do
      expect(client).to receive(:put).with('nodes/test-grid/node', {
          labels: [],
      })
      subject.run(['node', 'test=yes'])
    end
  end

  context "for a node with labels" do
    let :node do
      {
        "id" => 'test-grid/node',
        "name" => "node",
        "labels" => [
          'test=yes',
          'test=no',
        ],
      }
    end

    it "removes labels" do
      expect(client).to receive(:put).with('nodes/test-grid/node', {
          labels: ['test=no'],
      })

      subject.run(['node', 'test=yes'])
    end

    it "removes all labels" do
      expect(client).to receive(:put).with('nodes/test-grid/node', {
          labels: [],
      })

      subject.run(['node', 'test=yes', 'test=no'])
    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
kontena-cli-1.4.3 spec/kontena/cli/nodes/labels/remove_command_spec.rb
kontena-cli-1.4.3.rc1 spec/kontena/cli/nodes/labels/remove_command_spec.rb
kontena-cli-1.4.2 spec/kontena/cli/nodes/labels/remove_command_spec.rb
kontena-cli-1.4.2.rc1 spec/kontena/cli/nodes/labels/remove_command_spec.rb
kontena-cli-1.4.2.pre1 spec/kontena/cli/nodes/labels/remove_command_spec.rb
kontena-cli-1.4.1 spec/kontena/cli/nodes/labels/remove_command_spec.rb
kontena-cli-1.4.1.rc1 spec/kontena/cli/nodes/labels/remove_command_spec.rb
kontena-cli-1.4.1.pre1 spec/kontena/cli/nodes/labels/remove_command_spec.rb
kontena-cli-1.4.0 spec/kontena/cli/nodes/labels/remove_command_spec.rb
kontena-cli-1.4.0.rc2 spec/kontena/cli/nodes/labels/remove_command_spec.rb
kontena-cli-1.4.0.rc1 spec/kontena/cli/nodes/labels/remove_command_spec.rb
kontena-cli-1.4.0.pre14 spec/kontena/cli/nodes/labels/remove_command_spec.rb
kontena-cli-1.4.0.pre13 spec/kontena/cli/nodes/labels/remove_command_spec.rb
kontena-cli-1.4.0.pre12 spec/kontena/cli/nodes/labels/remove_command_spec.rb
kontena-cli-1.4.0.pre11 spec/kontena/cli/nodes/labels/remove_command_spec.rb
kontena-cli-1.4.0.pre10 spec/kontena/cli/nodes/labels/remove_command_spec.rb
kontena-cli-1.4.0.pre9 spec/kontena/cli/nodes/labels/remove_command_spec.rb
kontena-cli-1.4.0.pre8 spec/kontena/cli/nodes/labels/remove_command_spec.rb
kontena-cli-1.4.0.pre7 spec/kontena/cli/nodes/labels/remove_command_spec.rb
kontena-cli-1.4.0.pre6 spec/kontena/cli/nodes/labels/remove_command_spec.rb