require 'spec_helper' describe 'App42::Command' do describe "App" do before(:all) do @app_name = 'demo' @new_app_name = 'demo1' @existing_app_name = 'demo' @iaas = 1 @vm_type = 'Shared' @runtime = 4 @framework = 4 @web_server = 4 @os = 1 @vm_config = 1 @instance = 1 end context "With valid input data" do it 'Should return app name available' do response = App42::Command::Base.new.app_url_availability @new_app_name, @iaas, @vm_type response.should eql true end it 'Should setup infrastructure' do response = App42::Command::Base.new.create_infrastructure @app_name, @iaas, @vm_type, @runtime, @framework, @web_server, @os, @vm_config response.should eql true end it 'should list all apps' do response = App42::Command::App.new.apps end it 'Should scale app by instance 1:' do response = App42::Command::Base.new.scale_or_descale_app 'scale', @instance, @app_name response.should eql true end it 'Should descale app by instance 1:' do response = App42::Command::Base.new.scale_or_descale_app 'descale', @instance, @app_name response.should eql true end it 'Should start app:' do response = App42::Command::Base.new.app_operation 'start', @app_name response.should eql true end it 'Should stop app:' do response = App42::Command::Base.new.app_operation 'stop', @app_name response.should eql true end it 'Should restart app:' do response = App42::Command::Base.new.app_operation 'restart', @app_name response.should eql true end it 'Should return correct app information json' do respone = App42::Command::Base.new.app_information 'info', @app_name path = "#{APP_ROOT}/app42/spec/data/info.yml" info = YAML.load_file(path) respone.should eql info end it 'Should return correct app state json' do respone = App42::Command::Base.new.app_information 'state', @app_name path = "#{APP_ROOT}/app42/spec/data/state.yml" info = YAML.load_file(path) respone.should eql info end it 'Should delete app:' do response = App42::Command::Base.new.app_operation 'delete', @app_name response.should eql true end end context "Check app name availability with existing app name" do it 'Should return rest exception: App with name demo is not available.' do response = App42::Command::Base.new.app_url_availability @existing_app_name, @iaas, @vm_type puts response end end context "Setup-infra with existing app name" do it 'Should return rest exception: App with name demo is not available.' do response = App42::Command::Base.new.create_infrastructure @existing_app_name, @iaas, @vm_type, @runtime, @framework, @web_server, @os, @vm_config response.should eql true end end context "Setup-infra with existing app name" do it 'Should return rest exception: App with name demo is not available.' do response = App42::Command::Base.new.create_infrastructure @existing_app_name, @iaas, @vm_type, @runtime, @framework, @web_server, @os, @vm_config response.should eql true end end end end