Sha256: 62e8afdd17fb7f5f1052f67cc880e57eb65c0c5785fe297fe877fd09437bfe1a

Contents?: true

Size: 1.62 KB

Versions: 13

Compression:

Stored size: 1.62 KB

Contents

# -*- coding: utf-8 -*-
require 'spec_helper'

describe Magellan::Cli::Resources::Worker do

  let(:cmd){ Magellan::Cli::Resources::Worker.new }

  let(:http_conn){ double(:http_conn, :check_login_auth! => nil) }
  before{ allow(cmd).to receive(:http_conn).and_return(http_conn) }

  describe :update do
    describe :success do
      before do
        allow(cmd).to receive(:load_selections).and_return(
                        {Magellan::Cli::Resources::Worker.parameter_name => {"id" => 3, "name" => "worker1"}})
      end

      it "update name" do
        attrs = {"name" => "worker2"}
        res = {"id" => 3, "name" => "worker2"}
        expect(cmd).to receive(:put_json).with("/admin/functions~worker/3/edit.js", { "functions_worker" => attrs })
        allow(cmd).to receive(:default_query).and_return({})
        allow(cmd).to receive(:get_json).with("/admin/functions~worker.json", an_instance_of(Hash)).and_return([res])
        allow(cmd).to receive(:update_selections!).with("functions_worker" => res)
        allow(cmd).to receive(:update_selections!)
        cmd.update(attrs.to_json)
      end

      it "update image_name" do
        attrs = {"image_name" => "groovenauts/worker:0.0.1"}
        res = {"id" => 3, "image_name" => "groovenauts/worker:0.0.2"}
        expect(cmd).to receive(:put_json).with("/admin/functions~worker/3/edit.js", { "functions_worker" => attrs })
        allow(cmd).to receive(:default_query).and_return({})
        expect(cmd).to_not receive(:update_selections!).with("functions_worker" => res)
        expect(cmd).to_not receive(:update_selections!)
        cmd.update(attrs.to_json)
      end
    end
  end

end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
magellan-cli-0.11.1 spec/magellan/cli/resources/worker_spec.rb
magellan-cli-0.11.0 spec/magellan/cli/resources/worker_spec.rb
magellan-cli-0.10.0 spec/magellan/cli/resources/worker_spec.rb
magellan-cli-0.9.1 spec/magellan/cli/resources/worker_spec.rb
magellan-cli-0.9.0 spec/magellan/cli/resources/worker_spec.rb
magellan-cli-0.8.3 spec/magellan/cli/resources/worker_spec.rb
magellan-cli-0.8.2 spec/magellan/cli/resources/worker_spec.rb
magellan-cli-0.8.1 spec/magellan/cli/resources/worker_spec.rb
magellan-cli-0.8.0 spec/magellan/cli/resources/worker_spec.rb
magellan-cli-0.7.11 spec/magellan/cli/resources/worker_spec.rb
magellan-cli-0.7.10 spec/magellan/cli/resources/worker_spec.rb
magellan-cli-0.7.9 spec/magellan/cli/resources/worker_spec.rb
magellan-cli-0.7.8 spec/magellan/cli/resources/worker_spec.rb