MuranoCLI 3.2.1.pre.beta.6 → 3.2.1.pre.beta.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/HISTORY.md +10 -0
- data/MuranoCLI.gemspec +37 -6
- data/Rakefile +38 -11
- data/lib/MrMurano/commands/business.rb +0 -4
- data/lib/MrMurano/version.rb +1 -1
- metadata +2 -251
- data/dockers/Dockerfile.2.2.9 +0 -40
- data/dockers/Dockerfile.2.3.6 +0 -40
- data/dockers/Dockerfile.2.4.3 +0 -40
- data/dockers/Dockerfile.2.5.0 +0 -40
- data/dockers/Dockerfile.GemRelease +0 -49
- data/dockers/Dockerfile.m4 +0 -122
- data/dockers/README.rst +0 -362
- data/dockers/RELEASE.rst +0 -135
- data/dockers/docker-test.sh +0 -163
- data/dockers/gem-release.sh +0 -4
- data/docs/basic_example.rst +0 -436
- data/docs/ci/.trustme.plugin +0 -140
- data/docs/ci/.trustme.sh +0 -516
- data/docs/ci/.trustme.vim +0 -55
- data/docs/completions/murano_completion-bash +0 -4484
- data/docs/demo.md +0 -109
- data/docs/develop.rst +0 -392
- data/docs/release.rst +0 -295
- data/spec/Account-Passwords_spec.rb +0 -245
- data/spec/Account_spec.rb +0 -256
- data/spec/Business_spec.rb +0 -307
- data/spec/ConfigFile_spec.rb +0 -55
- data/spec/ConfigMigrate_spec.rb +0 -108
- data/spec/Config_spec.rb +0 -440
- data/spec/Content_spec.rb +0 -422
- data/spec/GatewayBase_spec.rb +0 -65
- data/spec/GatewayDevice_spec.rb +0 -403
- data/spec/GatewayResource_spec.rb +0 -283
- data/spec/GatewaySettings_spec.rb +0 -130
- data/spec/HttpAuthed_spec.rb +0 -87
- data/spec/Http_spec.rb +0 -220
- data/spec/MakePretties_spec.rb +0 -127
- data/spec/Mock_spec.rb +0 -62
- data/spec/ProjectFile_spec.rb +0 -381
- data/spec/Setting_spec.rb +0 -120
- data/spec/Solution-ServiceConfig_spec.rb +0 -272
- data/spec/Solution-ServiceEventHandler_spec.rb +0 -442
- data/spec/Solution-ServiceModules_spec.rb +0 -562
- data/spec/Solution-UsersRoles_spec.rb +0 -269
- data/spec/Solution_spec.rb +0 -140
- data/spec/SyncRoot_spec.rb +0 -111
- data/spec/SyncUpDown_spec.rb +0 -868
- data/spec/Verbosing_spec.rb +0 -332
- data/spec/Webservice-Cors_spec.rb +0 -225
- data/spec/Webservice-Endpoint_spec.rb +0 -650
- data/spec/Webservice-File_spec.rb +0 -282
- data/spec/Webservice-Setting_spec.rb +0 -105
- data/spec/_workspace.rb +0 -43
- data/spec/cmd_business_spec.rb +0 -64
- data/spec/cmd_common.rb +0 -507
- data/spec/cmd_config_spec.rb +0 -73
- data/spec/cmd_content_spec.rb +0 -109
- data/spec/cmd_cors_spec.rb +0 -54
- data/spec/cmd_device_spec.rb +0 -130
- data/spec/cmd_domain_spec.rb +0 -62
- data/spec/cmd_element_spec.rb +0 -401
- data/spec/cmd_exchange_spec.rb +0 -114
- data/spec/cmd_help_spec.rb +0 -72
- data/spec/cmd_init_spec.rb +0 -475
- data/spec/cmd_keystore_spec.rb +0 -97
- data/spec/cmd_link_spec.rb +0 -105
- data/spec/cmd_logs_spec.rb +0 -162
- data/spec/cmd_password_spec.rb +0 -64
- data/spec/cmd_setting_application_spec.rb +0 -300
- data/spec/cmd_setting_product_spec.rb +0 -246
- data/spec/cmd_status_spec.rb +0 -300
- data/spec/cmd_syncdown_application_spec.rb +0 -128
- data/spec/cmd_syncdown_both_spec.rb +0 -178
- data/spec/cmd_syncdown_unit_spec.rb +0 -861
- data/spec/cmd_syncup_spec.rb +0 -148
- data/spec/cmd_token_spec.rb +0 -53
- data/spec/cmd_usage_spec.rb +0 -79
- data/spec/dry_run_formatter.rb +0 -28
- data/spec/fixtures/.mrmuranorc +0 -9
- data/spec/fixtures/ProjectFiles/invalid.yaml +0 -9
- data/spec/fixtures/ProjectFiles/only_meta.yaml +0 -24
- data/spec/fixtures/ProjectFiles/with_routes.yaml +0 -27
- data/spec/fixtures/SolutionFiles/0.2.0.json +0 -20
- data/spec/fixtures/SolutionFiles/0.2.0_invalid.json +0 -18
- data/spec/fixtures/SolutionFiles/0.2.json +0 -21
- data/spec/fixtures/SolutionFiles/0.3.0.json +0 -20
- data/spec/fixtures/SolutionFiles/0.3.0_invalid.json +0 -19
- data/spec/fixtures/SolutionFiles/0.3.json +0 -20
- data/spec/fixtures/SolutionFiles/basic.json +0 -20
- data/spec/fixtures/SolutionFiles/secret.json +0 -6
- data/spec/fixtures/configfile +0 -9
- data/spec/fixtures/dumped_config +0 -57
- data/spec/fixtures/exchange_element/element-show.json +0 -1
- data/spec/fixtures/exchange_element/swagger-mur-6407__10k.yaml +0 -282
- data/spec/fixtures/exchange_element/swagger-mur-6407__20k.yaml +0 -588
- data/spec/fixtures/gateway_resource_files/resources.notyaml +0 -12
- data/spec/fixtures/gateway_resource_files/resources.yaml +0 -13
- data/spec/fixtures/gateway_resource_files/resources_invalid.yaml +0 -13
- data/spec/fixtures/mrmuranorc_deleted_bob +0 -6
- data/spec/fixtures/mrmuranorc_tool_bob +0 -3
- data/spec/fixtures/product_spec_files/example.exoline.spec.yaml +0 -116
- data/spec/fixtures/product_spec_files/example.murano.spec.yaml +0 -14
- data/spec/fixtures/product_spec_files/gwe.exoline.spec.yaml +0 -21
- data/spec/fixtures/product_spec_files/gwe.murano.spec.yaml +0 -16
- data/spec/fixtures/product_spec_files/lightbulb-no-state.yaml +0 -11
- data/spec/fixtures/product_spec_files/lightbulb.yaml +0 -21
- data/spec/fixtures/roles-three.yaml +0 -11
- data/spec/fixtures/snapshots/murano application setting Writes (using Webservice.cors) a bool value 0.webmock +0 -98
- data/spec/fixtures/snapshots/murano application setting Writes (using Webservice.cors) a bool value 1.webmock +0 -98
- data/spec/fixtures/snapshots/murano application setting Writes (using Webservice.cors) a bool value No.webmock +0 -98
- data/spec/fixtures/snapshots/murano application setting Writes (using Webservice.cors) a bool value Yes.webmock +0 -98
- data/spec/fixtures/snapshots/murano application setting Writes (using Webservice.cors) a bool value bob.webmock +0 -72
- data/spec/fixtures/snapshots/murano application setting Writes (using Webservice.cors) a bool value false.webmock +0 -98
- data/spec/fixtures/snapshots/murano application setting Writes (using Webservice.cors) a bool value off.webmock +0 -98
- data/spec/fixtures/snapshots/murano application setting Writes (using Webservice.cors) a bool value on STDIN.webmock +0 -98
- data/spec/fixtures/snapshots/murano application setting Writes (using Webservice.cors) a bool value on.webmock +0 -98
- data/spec/fixtures/snapshots/murano application setting Writes (using Webservice.cors) a bool value true.webmock +0 -98
- data/spec/fixtures/snapshots/murano application setting Writes (using Webservice.cors) a json array blob with STDIN.webmock +0 -98
- data/spec/fixtures/snapshots/murano application setting Writes (using Webservice.cors) a json array blob.webmock +0 -98
- data/spec/fixtures/snapshots/murano application setting Writes (using Webservice.cors) an array.webmock +0 -98
- data/spec/fixtures/snapshots/murano application setting Writes (using Webservice.cors) appends an array.webmock +0 -98
- data/spec/fixtures/snapshots/murano application setting reads Webservice.cors to a file.webmock +0 -72
- data/spec/fixtures/snapshots/murano application setting reads Webservice.cors.webmock +0 -72
- data/spec/fixtures/snapshots/murano business list as json.webmock +0 -27
- data/spec/fixtures/snapshots/murano business list as table.webmock +0 -27
- data/spec/fixtures/snapshots/murano business list fewer fields.webmock +0 -27
- data/spec/fixtures/snapshots/murano business list only ids.webmock +0 -27
- data/spec/fixtures/snapshots/murano business list output to file.webmock +0 -27
- data/spec/fixtures/snapshots/murano business without project help.webmock +0 -9
- data/spec/fixtures/snapshots/murano config Needs a key.webmock +0 -9
- data/spec/fixtures/snapshots/murano config Reads a key.webmock +0 -9
- data/spec/fixtures/snapshots/murano config Removes a key.webmock +0 -9
- data/spec/fixtures/snapshots/murano config Sets a key.webmock +0 -9
- data/spec/fixtures/snapshots/murano config Sets a user key.webmock +0 -9
- data/spec/fixtures/snapshots/murano content life cycle.webmock +0 -144
- data/spec/fixtures/snapshots/murano cors sets CORS.webmock +0 -78
- data/spec/fixtures/snapshots/murano cors show CORS.webmock +0 -64
- data/spec/fixtures/snapshots/murano device activates.webmock +0 -86
- data/spec/fixtures/snapshots/murano device enables a batch.webmock +0 -76
- data/spec/fixtures/snapshots/murano device enables and lists.webmock +0 -78
- data/spec/fixtures/snapshots/murano device writes and reads.webmock +0 -136
- data/spec/fixtures/snapshots/murano domain show domain.webmock +0 -101
- data/spec/fixtures/snapshots/murano element edit unknown as unknown element.webmock +0 -43
- data/spec/fixtures/snapshots/murano element show --help.webmock +0 -9
- data/spec/fixtures/snapshots/murano element show as csv.webmock +0 -43
- data/spec/fixtures/snapshots/murano element show as default-table.webmock +0 -43
- data/spec/fixtures/snapshots/murano element show as json.webmock +0 -43
- data/spec/fixtures/snapshots/murano element show as table truncate.webmock +0 -43
- data/spec/fixtures/snapshots/murano element show as table wrap.webmock +0 -43
- data/spec/fixtures/snapshots/murano element show as yaml.webmock +0 -43
- data/spec/fixtures/snapshots/murano element show using ambiguous name.webmock +0 -43
- data/spec/fixtures/snapshots/murano element without project usage.webmock +0 -9
- data/spec/fixtures/snapshots/murano exchange with project list as json.webmock +0 -59
- data/spec/fixtures/snapshots/murano exchange with project list as table.webmock +0 -59
- data/spec/fixtures/snapshots/murano exchange with project list fewer fields.webmock +0 -59
- data/spec/fixtures/snapshots/murano exchange with project list only ids.webmock +0 -59
- data/spec/fixtures/snapshots/murano exchange with project list output to file.webmock +0 -59
- data/spec/fixtures/snapshots/murano exchange with project list purchase is already added ID.webmock +0 -83
- data/spec/fixtures/snapshots/murano exchange with project list purchase is ambiguous name.webmock +0 -59
- data/spec/fixtures/snapshots/murano exchange without project help.webmock +0 -9
- data/spec/fixtures/snapshots/murano help using commander as --help.webmock +0 -9
- data/spec/fixtures/snapshots/murano help using commander no args.webmock +0 -9
- data/spec/fixtures/snapshots/murano help using subshell no args.webmock +0 -9
- data/spec/fixtures/snapshots/murano help using subshell with --help.webmock +0 -9
- data/spec/fixtures/snapshots/murano init Won't init in HOME (gracefully).webmock +0 -9
- data/spec/fixtures/snapshots/murano init in empty directory with existing project.webmock +0 -201
- data/spec/fixtures/snapshots/murano init in empty directory without existing project.webmock +0 -193
- data/spec/fixtures/snapshots/murano init in existing project directory with ProjectFile.webmock +0 -213
- data/spec/fixtures/snapshots/murano init in existing project directory with SolutionFile 0.2.0.webmock +0 -213
- data/spec/fixtures/snapshots/murano init in existing project directory with SolutionFile 0.3.0.webmock +0 -213
- data/spec/fixtures/snapshots/murano init in existing project directory without ProjectFile.webmock +0 -213
- data/spec/fixtures/snapshots/murano keystore can call other commands.webmock +0 -108
- data/spec/fixtures/snapshots/murano keystore clearAll.webmock +0 -124
- data/spec/fixtures/snapshots/murano keystore deletes.webmock +0 -112
- data/spec/fixtures/snapshots/murano keystore gets.webmock +0 -96
- data/spec/fixtures/snapshots/murano keystore infos.webmock +0 -96
- data/spec/fixtures/snapshots/murano keystore lists.webmock +0 -96
- data/spec/fixtures/snapshots/murano link with project links and lists.webmock +0 -149
- data/spec/fixtures/snapshots/murano link with project unlinks.webmock +0 -165
- data/spec/fixtures/snapshots/murano link without project help.webmock +0 -9
- data/spec/fixtures/snapshots/murano link without project subshell vs inline using commander will not list.webmock +0 -27
- data/spec/fixtures/snapshots/murano link without project subshell vs inline using subshell will not list.webmock +0 -27
- data/spec/fixtures/snapshots/murano logs when project is setup tail log.webmock +0 -9
- data/spec/fixtures/snapshots/murano password Lists when no file.webmock +0 -9
- data/spec/fixtures/snapshots/murano password deletes a password.webmock +0 -9
- data/spec/fixtures/snapshots/murano password sets a password.webmock +0 -9
- data/spec/fixtures/snapshots/murano product setting Writes (using Device2.identity_format) a forced string value on STDIN.webmock +0 -90
- data/spec/fixtures/snapshots/murano product setting Writes (using Device2.identity_format) a forced string value.webmock +0 -90
- data/spec/fixtures/snapshots/murano product setting Writes (using Device2.identity_format) a number value fiftyHalf.webmock +0 -64
- data/spec/fixtures/snapshots/murano product setting Writes (using Device2.identity_format) a number value float 12.67.webmock +0 -90
- data/spec/fixtures/snapshots/murano product setting Writes (using Device2.identity_format) a number value integer 12.webmock +0 -90
- data/spec/fixtures/snapshots/murano product setting Writes (using Device2.identity_format) a number value on STDIN.webmock +0 -90
- data/spec/fixtures/snapshots/murano product setting Writes (using Device2.identity_format) a string value.webmock +0 -90
- data/spec/fixtures/snapshots/murano product setting Writes (using Device2.identity_format) merges into a dictionary.webmock +0 -90
- data/spec/fixtures/snapshots/murano single sync without ProjectFile syncdown.webmock +0 -322
- data/spec/fixtures/snapshots/murano status with ProjectFile status.webmock +0 -153
- data/spec/fixtures/snapshots/murano status with Solutionfile 0.2.0 status.webmock +0 -153
- data/spec/fixtures/snapshots/murano status with Solutionfile 0.3.0 status.webmock +0 -153
- data/spec/fixtures/snapshots/murano status without ProjectFile matches file path.webmock +0 -153
- data/spec/fixtures/snapshots/murano status without ProjectFile matches route.webmock +0 -153
- data/spec/fixtures/snapshots/murano status without ProjectFile status.webmock +0 -153
- data/spec/fixtures/snapshots/murano syncdown stubbed without ProjectFile syncdown.webmock +0 -151
- data/spec/fixtures/snapshots/murano syncdown without ProjectFile syncdown.webmock +0 -479
- data/spec/fixtures/snapshots/murano syncup without ProjectFile syncup.webmock +0 -357
- data/spec/fixtures/snapshots/murano token with project list as table.webmock +0 -9
- data/spec/fixtures/snapshots/murano token without project help.webmock +0 -9
- data/spec/fixtures/snapshots/murano usage show usage.webmock +0 -93
- data/spec/fixtures/syncable_conflict/services/devdata.lua +0 -18
- data/spec/fixtures/syncable_conflict/services/timers.lua +0 -4
- data/spec/fixtures/syncable_content/assets/icon.png +0 -0
- data/spec/fixtures/syncable_content/assets/index.html +0 -0
- data/spec/fixtures/syncable_content/assets/js/script.js +0 -0
- data/spec/fixtures/syncable_content/modules/table_util.lua +0 -58
- data/spec/fixtures/syncable_content/routes/manyRoutes.lua +0 -11
- data/spec/fixtures/syncable_content/routes/singleRoute.lua +0 -5
- data/spec/fixtures/websocket/README.rst +0 -110
- data/spec/fixtures/websocket/logs_blather.rb +0 -27
- data/spec/fixtures/websocket/logs_faker.rb +0 -153
- data/spec/fixtures/websocket/simple_connection.rb +0 -45
- data/spec/fixtures/websocket/simple_options.rb +0 -77
- data/spec/fixtures/websocket/simple_server.rb +0 -69
- data/spec/fixtures/websocket/wss-echo.rb +0 -48
- data/spec/fixtures/websocket/wss-fake-logs.rb +0 -20
- data/spec/spec_helper.rb +0 -131
- data/spec/variegated_TruthyFalsey_spec.rb +0 -29
- data/spec/webmock_snapshot.rb +0 -296
data/spec/cmd_common.rb
DELETED
@@ -1,507 +0,0 @@
|
|
1
|
-
# Copyright © 2016-2017 Exosite LLC. All Rights Reserved
|
2
|
-
# License: PROPRIETARY. See LICENSE.txt.
|
3
|
-
# frozen_string_literal: true
|
4
|
-
|
5
|
-
# vim:tw=0:ts=2:sw=2:et:ai
|
6
|
-
# Unauthorized copying of this file is strictly prohibited.
|
7
|
-
|
8
|
-
require 'highline'
|
9
|
-
# Set HighLine's $terminal global.
|
10
|
-
require 'highline/import'
|
11
|
-
require 'os'
|
12
|
-
require 'pathname'
|
13
|
-
require 'rainbow'
|
14
|
-
require 'shellwords'
|
15
|
-
require 'time'
|
16
|
-
require 'timeout'
|
17
|
-
require 'tmpdir'
|
18
|
-
require 'webmock/rspec'
|
19
|
-
|
20
|
-
require 'MrMurano/progress'
|
21
|
-
require 'MrMurano/Config'
|
22
|
-
require 'MrMurano/HttpAuthed'
|
23
|
-
|
24
|
-
require 'webmock_snapshot'
|
25
|
-
|
26
|
-
# Prevent Commander from registering its at_exit hook.
|
27
|
-
# - Also print warning if spec exits, which rspec doesn't see as wrong.
|
28
|
-
# - Note that this comes before importing Commander.
|
29
|
-
$exited_abnormally = false
|
30
|
-
|
31
|
-
$catpured_io = false
|
32
|
-
|
33
|
-
def capture_stdio
|
34
|
-
return if $catpured_io
|
35
|
-
$murcli_wasin = $stdin # (lb): Could probably just use STDIN and skip this global.
|
36
|
-
$murcli_wasout = $stdout
|
37
|
-
$murcli_waserr = $stderr
|
38
|
-
$murcli_wasterm = $terminal
|
39
|
-
$catpured_io = true
|
40
|
-
end
|
41
|
-
capture_stdio
|
42
|
-
|
43
|
-
def restore_stdio
|
44
|
-
return unless $catpured_io
|
45
|
-
$stdin = $murcli_wasin
|
46
|
-
$stdout = $murcli_wasout
|
47
|
-
$stderr = $murcli_waserr
|
48
|
-
$terminal = $murcli_wasterm
|
49
|
-
$murcli_wasin = nil
|
50
|
-
$murcli_wasout = nil
|
51
|
-
$murcli_waserr = nil
|
52
|
-
$murcli_wasterm = nil
|
53
|
-
$catpured_io = false
|
54
|
-
end
|
55
|
-
|
56
|
-
at_exit do
|
57
|
-
if $exited_abnormally
|
58
|
-
restore_stdio
|
59
|
-
warn('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!')
|
60
|
-
warn(%( ____ ))
|
61
|
-
warn(%{ ,%( Y`. })
|
62
|
-
warn(%( / \ ))
|
63
|
-
warn(%( \ () () / ))
|
64
|
-
warn(%{ `. /\ ,%( })
|
65
|
-
warn(%( 8====| "" |====8 ))
|
66
|
-
warn(%( `LLLU' ))
|
67
|
-
warn(%( ))
|
68
|
-
warn('¡Unexpected spec exit killed rspec!')
|
69
|
-
warn('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!')
|
70
|
-
# DEVs: If you see this message, the last test exited unexpectedly.
|
71
|
-
warn('')
|
72
|
-
warn("Died on: #{$exited_abnormally}")
|
73
|
-
warn('')
|
74
|
-
end
|
75
|
-
end
|
76
|
-
alias original_at_exit at_exit unless defined?(original_at_exit)
|
77
|
-
|
78
|
-
def at_exit(*args, &block)
|
79
|
-
#original_at_exit *args, &block
|
80
|
-
# pass!
|
81
|
-
end
|
82
|
-
|
83
|
-
require 'MrMurano/Commander-Entry'
|
84
|
-
|
85
|
-
module Commander
|
86
|
-
class Command
|
87
|
-
attr_writer :when_called
|
88
|
-
#def when_called=(args)
|
89
|
-
# @when_called = args
|
90
|
-
#end
|
91
|
-
|
92
|
-
def peek_when_called
|
93
|
-
@when_called
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
class Runner
|
98
|
-
def force_args(args)
|
99
|
-
@args = args
|
100
|
-
end
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
RSpec.shared_context 'CI_CMD' do
|
105
|
-
# capcmd makes an Open3-ready `murano` command from a list of args.
|
106
|
-
def capcmd(*args)
|
107
|
-
args = [args] unless args.is_a? Array
|
108
|
-
args.flatten!
|
109
|
-
testdir = File.realpath(@testdir.to_s)
|
110
|
-
if ENV['CI_MR_EXE'].nil?
|
111
|
-
args[0] = File.join(testdir, 'bin', args[0])
|
112
|
-
args.unshift('ruby', "-I#{File.join(testdir, 'lib')}")
|
113
|
-
else
|
114
|
-
args[0] = File.join(testdir, (args[0] + '.exe'))
|
115
|
-
end
|
116
|
-
args.push '--trace'
|
117
|
-
args.push '-c', 'fullerror'
|
118
|
-
# The spinner output would make it hard to write expects().
|
119
|
-
args.push '--no-progress'
|
120
|
-
|
121
|
-
# FIXME: (lb): Is this necessary? Commenting out for now; will delete later.
|
122
|
-
## Save the token.
|
123
|
-
#args.push '--cache'
|
124
|
-
|
125
|
-
if Gem.win_platform?
|
126
|
-
cmd = args.map do |i|
|
127
|
-
case i
|
128
|
-
when /[ ]/
|
129
|
-
%("#{i}")
|
130
|
-
when /[\*#]/
|
131
|
-
i.gsub(/([\*#])/, '^\1')
|
132
|
-
else
|
133
|
-
i
|
134
|
-
end
|
135
|
-
end.join(' ')
|
136
|
-
else
|
137
|
-
cmd = Shellwords.join(args)
|
138
|
-
end
|
139
|
-
#pp cmd
|
140
|
-
cmd
|
141
|
-
end
|
142
|
-
|
143
|
-
# *** Utility fcns: symlinks.
|
144
|
-
|
145
|
-
# Makes a symlink to the /tmp project dir.
|
146
|
-
def mk_symlink
|
147
|
-
# Make it easy to debug tests, e.g., add breakpoint before capcmd('murano', ...)
|
148
|
-
# run test, then open another terminal window and `cd /tmp/murcli-test`.
|
149
|
-
# NOTE: When run on Jenkins, Dir.tmpdir() returns the path to the project directory!
|
150
|
-
# Since this is for DEVs only, we can hack around this.
|
151
|
-
tmpdir = Dir.tmpdir()
|
152
|
-
return unless tmpdir == '/tmp'
|
153
|
-
@dev_symlink = File.join(tmpdir, 'murcli-test')
|
154
|
-
FileUtils.rm(@dev_symlink, force: true)
|
155
|
-
begin
|
156
|
-
FileUtils.ln_s(Dir.pwd, @dev_symlink)
|
157
|
-
rescue NotImplementedError => err
|
158
|
-
# This happens on Windows...
|
159
|
-
require 'rbconfig'
|
160
|
-
# Check the platform, e.g., "linux-gnu", or other.
|
161
|
-
#is_windows = (
|
162
|
-
# RbConfig::CONFIG['host_os'] =~ /mswin|msys|mingw|cygwin|bccwin|wince|emc/
|
163
|
-
#)
|
164
|
-
unless OS.windows?
|
165
|
-
warn(
|
166
|
-
'Unexpected: ln_s failed on non-Windows machine / ' \
|
167
|
-
"host_os: #{RbConfig::CONFIG['host_os']} / err: #{err}"
|
168
|
-
)
|
169
|
-
end
|
170
|
-
end
|
171
|
-
end
|
172
|
-
|
173
|
-
# Removes the /tmp project directory symlink.
|
174
|
-
def rm_symlink
|
175
|
-
FileUtils.rm(@dev_symlink, force: true) if defined?(@dev_symlink)
|
176
|
-
end
|
177
|
-
|
178
|
-
# *** Utility fcns: Murano Solutions management: create/delete/expunge.
|
179
|
-
|
180
|
-
def murano_solutions_expunge_yes
|
181
|
-
out, err = murano_command_safe('solutions expunge', '-y')
|
182
|
-
expect(out).to \
|
183
|
-
eq('').or \
|
184
|
-
eq("No solutions found\n").or \
|
185
|
-
match(/^Deleted [\d]+ solutions?/)
|
186
|
-
expect(MrMurano::Progress.strip_color(err)).to eq('').or eq("No solutions found\n")
|
187
|
-
end
|
188
|
-
|
189
|
-
def project_up(skip_link: false)
|
190
|
-
# Preemptive clean up!
|
191
|
-
murano_solutions_expunge_yes if defined?(PRE_EXPUNGE) && PRE_EXPUNGE
|
192
|
-
|
193
|
-
@proj_name_prod = @snapshotter.resolve_var(
|
194
|
-
'product.name', rname('MurCLITestProd')
|
195
|
-
)
|
196
|
-
# NOTE: Do not use alias, which resolves to base command, but without options.
|
197
|
-
# E.g., use 'solution create', ...; and not 'product create'.
|
198
|
-
out, err = murano_command_run(
|
199
|
-
'solution create', '--type', 'product', @proj_name_prod, '--save',
|
200
|
-
)
|
201
|
-
expect(err).to eq('')
|
202
|
-
expect(out.chomp).to match(/^[a-zA-Z0-9]+$/)
|
203
|
-
|
204
|
-
@proj_name_appy = @snapshotter.resolve_var(
|
205
|
-
'application.name', rname('MurCLITestAppy')
|
206
|
-
)
|
207
|
-
out, err = murano_command_run(
|
208
|
-
'solution create', '--type', 'application', @proj_name_appy, '--save',
|
209
|
-
)
|
210
|
-
expect(err).to eq('')
|
211
|
-
soln_id = out
|
212
|
-
expect(soln_id.chomp).to match(/^[a-zA-Z0-9]+$/)
|
213
|
-
|
214
|
-
project_up_link unless skip_link
|
215
|
-
end
|
216
|
-
|
217
|
-
def project_up_link
|
218
|
-
out, err = murano_command_run('assign set')
|
219
|
-
olines = out.lines
|
220
|
-
expect(strip_fancy(olines[0])).to eq(
|
221
|
-
"Linked '#{@proj_name_prod}' to '#{@proj_name_appy}'\n"
|
222
|
-
)
|
223
|
-
expect(olines[1]).to eq("Created default event handler\n")
|
224
|
-
expect(err).to eq('')
|
225
|
-
end
|
226
|
-
|
227
|
-
def project_down
|
228
|
-
return if defined?(PRE_EXPUNGE) && PRE_EXPUNGE
|
229
|
-
|
230
|
-
out, err = murano_command_run('solution delete', @proj_name_appy, '-y')
|
231
|
-
expect(out).to eq('')
|
232
|
-
expect(err).to eq('')
|
233
|
-
|
234
|
-
out, err = murano_command_run('solution delete', @proj_name_prod, '-y')
|
235
|
-
expect(out).to eq('')
|
236
|
-
expect(err).to eq('')
|
237
|
-
end
|
238
|
-
|
239
|
-
# Utility fcns: Strings.
|
240
|
-
|
241
|
-
# rname makes a random Murano-acceptable Solution name.
|
242
|
-
def rname(name='')
|
243
|
-
#"#{name}-#{Random.new.rand.hash.abs.to_s(16)}"
|
244
|
-
# MUR-2454: Product name may only contain letters and numbers.
|
245
|
-
#"#{name}#{Random.new.rand.hash.abs.to_s(16)}"
|
246
|
-
# MUR-XXXX: Product name must be lowercase.
|
247
|
-
# 2017-06-01: From [cr]: "I'll be having bizapi convert to lower case
|
248
|
-
# in the short term, and pegasus is updating to allow upper case."
|
249
|
-
# LATER: Remove .downcase once PAAS fixed.
|
250
|
-
"#{name.downcase}#{Random.new.rand.hash.abs.to_s(16)}"
|
251
|
-
end
|
252
|
-
|
253
|
-
def strip_fancy(str)
|
254
|
-
# Windows has a complaint about the fancy quotes if you don't encode!, which is
|
255
|
-
#
|
256
|
-
# expected: "Linked \u2018syncdowntestprd1e8b4034\u2019
|
257
|
-
# to \u2018syncdowntestapp23d5135b\u2019\n"
|
258
|
-
# got: "Linked \xE2\x80\x98syncdowntestprd1e8b4034\xE2\x80\x99
|
259
|
-
# to \xE2\x80\x98syncdowntestapp23d5135b\xE2\x80\x99\n"
|
260
|
-
#
|
261
|
-
# or, to put it another way,
|
262
|
-
#
|
263
|
-
# -Linked ?syncdowntestprd1e8b4034? to ?syncdowntestapp23d5135b?
|
264
|
-
# +Linked ΓÇÿsyncdowntestprd1e8b4034ΓÇÖ to ΓÇÿsyncdowntestapp23d5135bΓÇÖ
|
265
|
-
#
|
266
|
-
# which we can solve with an encode call. (Or but using norm quotes.)
|
267
|
-
str.nil? && '' ||
|
268
|
-
str.encode!(
|
269
|
-
'UTF-8', 'UTF-8'
|
270
|
-
).tr(%(‘), %(')).tr(%(’), %('))
|
271
|
-
end
|
272
|
-
|
273
|
-
# *** rb-commander goodies
|
274
|
-
|
275
|
-
def murano_command_run(cmd, *args)
|
276
|
-
murano_command_runner(cmd, *args)
|
277
|
-
end
|
278
|
-
|
279
|
-
def murano_command_run_gentle(cmd, *args)
|
280
|
-
murano_command_runner(cmd, *args, skip_cfg: true)
|
281
|
-
end
|
282
|
-
|
283
|
-
def murano_command_exits(cmd, *args)
|
284
|
-
murano_command_runner(cmd, *args, wont_run: true)
|
285
|
-
end
|
286
|
-
|
287
|
-
def murano_command_safe(cmd, *args)
|
288
|
-
murano_command_runner(cmd, *args, wont_run: :unknown)
|
289
|
-
end
|
290
|
-
|
291
|
-
def murano_command_wont_parse(cmd, *args)
|
292
|
-
murano_command_runner(cmd, *args, wont_parse: true)
|
293
|
-
end
|
294
|
-
|
295
|
-
def murano_command_runner(
|
296
|
-
cmd, *args, wont_run: false, wont_parse: false, skip_cfg: false, stdin_data: nil
|
297
|
-
)
|
298
|
-
# DEVS: If you want to set a breakpoint within a command under test,
|
299
|
-
# you need to break into byebug before stdio is redirected.
|
300
|
-
# Just break, then [c]ontinue, and break again within the test,
|
301
|
-
# and then interactive debugging will work. I.e., uncomment this:
|
302
|
-
#
|
303
|
-
# require 'byebug' ; byebug if true
|
304
|
-
#
|
305
|
-
# Though really you just need to break once:
|
306
|
-
#
|
307
|
-
# require 'byebug' ; byebug if !defined?(@@broken)
|
308
|
-
# @@broken = true
|
309
|
-
|
310
|
-
capture_stdio
|
311
|
-
tmpout = StringIO.new
|
312
|
-
tmperr = StringIO.new
|
313
|
-
|
314
|
-
unless stdin_data.nil?
|
315
|
-
$stdin = StringIO.new
|
316
|
-
$stdin.print(stdin_data)
|
317
|
-
$stdin.rewind
|
318
|
-
end
|
319
|
-
|
320
|
-
# Commander's `say` calls HighLine's $terminal.say, so redirect that, too.
|
321
|
-
hline = HighLine.new($stdin, tmpout)
|
322
|
-
$terminal = hline
|
323
|
-
# DEVs: If you set a byebug break after this point, the byebug will
|
324
|
-
# show when the code breaks, but you'll see no echo or output. So
|
325
|
-
# comment this code out if you're debugging.
|
326
|
-
$stdout = tmpout
|
327
|
-
$stderr = tmperr
|
328
|
-
|
329
|
-
$exited_abnormally = "#{cmd} #{args.join(' ')}"
|
330
|
-
|
331
|
-
MrMurano::HttpAuthed.instance.credentials_reset
|
332
|
-
|
333
|
-
# When Commander is loaded, it sets an at_exit hook, which we monkey
|
334
|
-
# patch in ReCommander. Since Config.validate_cmd is called before
|
335
|
-
# at_exit, it uses runner.command_exit to tell ReCommander's at_exit
|
336
|
-
# monkey patch not to call Commander.run!. Via rspec, we don't use the
|
337
|
-
# at_exit hook, or ReCommander.
|
338
|
-
unless skip_cfg
|
339
|
-
$cfg = MrMurano::Config.new(::Commander::Runner.instance)
|
340
|
-
$cfg.load
|
341
|
-
$cfg['tool.no-progress'] = true
|
342
|
-
|
343
|
-
# In case the test runner installed a project file.
|
344
|
-
$project = MrMurano::ProjectFile.new
|
345
|
-
$project.load
|
346
|
-
end
|
347
|
-
$cfg.validate_cmd
|
348
|
-
|
349
|
-
runner = ::Commander::Runner.instance
|
350
|
-
unless defined?(runner.command_exit) && runner.command_exit
|
351
|
-
# (lb): Commander's at_exit hook calls runner.run! which runs the
|
352
|
-
# command that was determined with Commander was loaded. I tried a
|
353
|
-
# few different ways to reset Runner.instance, but nothing worked;
|
354
|
-
# our best bet is to just call the command directly.
|
355
|
-
the_cmd = command(cmd.to_sym)
|
356
|
-
raise "Specified command not recognized! “#{cmd}”" if the_cmd.nil?
|
357
|
-
when_called = the_cmd.peek_when_called.dup
|
358
|
-
|
359
|
-
runner.force_args(args.dup)
|
360
|
-
#runner.parse_global_options
|
361
|
-
if wont_parse
|
362
|
-
expect { runner.old_parse_global_options }.to raise_error(SystemExit)
|
363
|
-
else
|
364
|
-
runner.old_parse_global_options
|
365
|
-
runner.remove_global_options runner.options, args
|
366
|
-
if wont_run == true
|
367
|
-
expect { the_cmd.run(*args) }.to raise_error(SystemExit)
|
368
|
-
else
|
369
|
-
begin
|
370
|
-
the_cmd.run(*args)
|
371
|
-
rescue StandardError => _err
|
372
|
-
# This is unexpected. Leave $exited_abnormally so we warn the user.
|
373
|
-
restore_stdio
|
374
|
-
raise
|
375
|
-
rescue SystemExit => _err
|
376
|
-
if wont_run != :unknown
|
377
|
-
# This happens if the CLI calls exit, but the test runner was not
|
378
|
-
# expecting it to exit (because otherwise the test runner would
|
379
|
-
# have called this method with wont_run: true). So long as our
|
380
|
-
# $exited_abnormally works as intended, we have nothing to do.
|
381
|
-
restore_stdio
|
382
|
-
unless tmpout.string.empty?
|
383
|
-
puts "ERROR: Unexpected `exit`: out: #{tmpout.string}"
|
384
|
-
end
|
385
|
-
unless tmperr.string.empty?
|
386
|
-
puts "ERROR: Unexpected `exit`: err: #{tmperr.string}"
|
387
|
-
end
|
388
|
-
if tmpout.string.empty? && tmperr.string.empty?
|
389
|
-
puts 'ERROR: Unexpected `exit`: but no stdout nor stderr message'
|
390
|
-
end
|
391
|
-
raise
|
392
|
-
end
|
393
|
-
end
|
394
|
-
end
|
395
|
-
end
|
396
|
-
|
397
|
-
# Reset proxy_options otherwise Commander::Command.call
|
398
|
-
# uses them the next time this command is called.
|
399
|
-
the_cmd.proxy_options = []
|
400
|
-
the_cmd.when_called = when_called
|
401
|
-
end
|
402
|
-
runner.command_exit = nil
|
403
|
-
|
404
|
-
$exited_abnormally = false
|
405
|
-
# Ruby provides std i/o constants, so we could do this:
|
406
|
-
# $stdout, $stderr = STDOUT, STDERR
|
407
|
-
restore_stdio
|
408
|
-
|
409
|
-
HighLine.use_color = true
|
410
|
-
Rainbow.enabled = true
|
411
|
-
|
412
|
-
[
|
413
|
-
MrMurano::Progress.strip_color(tmpout.string),
|
414
|
-
MrMurano::Progress.strip_color(tmperr.string),
|
415
|
-
]
|
416
|
-
end
|
417
|
-
|
418
|
-
def cmd_verify_help(cmd_name)
|
419
|
-
stdout, stderr = murano_command_run(cmd_name)
|
420
|
-
expect(stdout).to start_with(
|
421
|
-
" NAME:\n\n murano #{cmd_name}\n\n DESCRIPTION:\n\n "
|
422
|
-
)
|
423
|
-
expect(stderr).to eq('')
|
424
|
-
end
|
425
|
-
|
426
|
-
# *** before() and around()
|
427
|
-
|
428
|
-
before(:context) do
|
429
|
-
@timeit_time0 = Time.now
|
430
|
-
end
|
431
|
-
|
432
|
-
after(:context) do
|
433
|
-
elapsed_secs = Time.now - @timeit_time0
|
434
|
-
puts "\n .. elapsed: #{elapsed_secs.round(2)} secs."
|
435
|
-
end
|
436
|
-
|
437
|
-
# Before: Load Config.
|
438
|
-
before(:example) do |example|
|
439
|
-
$cfg = MrMurano::Config.new
|
440
|
-
$cfg.load
|
441
|
-
|
442
|
-
# Manage snapshot testing.
|
443
|
-
@snapshotter = MrMurano::Snapshot::WebMock.instance
|
444
|
-
@snapshotter.reset(example)
|
445
|
-
@snapshotter.establish_mocks
|
446
|
-
end
|
447
|
-
|
448
|
-
after(:example) do
|
449
|
-
@snapshotter.terminate_mocks
|
450
|
-
end
|
451
|
-
|
452
|
-
# Around: Make project dir under /tmp.
|
453
|
-
around(:example) do |example|
|
454
|
-
# Load the byebug library now, before changing directories.
|
455
|
-
# This sets Setting[:histfile]. Within byebug, try `show histfile`.
|
456
|
-
# Make sure this is set now, otherwise, byebug crashes, e.g.,
|
457
|
-
# <Errno::ENOENT: No such file or directory @ rb_sysopen -
|
458
|
-
# /tmp/d20170830-10087-h7tq6a/project/.byebug_history>
|
459
|
-
# This happens if the first call to byebug is after the chdir.
|
460
|
-
# Byebug creates the histfile in the tmp dir. So the next time
|
461
|
-
# the method containing `byebug` is called, it's from within a
|
462
|
-
# different tmp dir, and the old tmp dir has been removed. So
|
463
|
-
# byebug crashes trying to access the old, missing histfile.
|
464
|
-
require 'byebug/settings/histfile'
|
465
|
-
_ignored = ::Byebug::HistfileSetting::DEFAULT
|
466
|
-
|
467
|
-
$exited_abnormally = example.example.to_s
|
468
|
-
|
469
|
-
@testdir = Pathname.new(Dir.pwd).realpath
|
470
|
-
Dir.mktmpdir do |hdir|
|
471
|
-
saved_home = Dir.home
|
472
|
-
ENV['HOME'] = hdir
|
473
|
-
Dir.chdir(hdir) do
|
474
|
-
Dir.mkdir('.murano')
|
475
|
-
|
476
|
-
Dir.chdir('.murano') do
|
477
|
-
begin
|
478
|
-
FileUtils.ln_s(File.join(saved_home, '.murano', 'tokens'), 'tokens')
|
479
|
-
rescue NotImplementedError => err
|
480
|
-
require 'rbconfig'
|
481
|
-
unless OS.windows?
|
482
|
-
warn(
|
483
|
-
'Unexpected: ln_s failed on non-Windows machine / ' \
|
484
|
-
"host_os: #{RbConfig::CONFIG['host_os']} / err: #{err}"
|
485
|
-
)
|
486
|
-
end
|
487
|
-
end
|
488
|
-
end
|
489
|
-
|
490
|
-
@tmpdir = File.join(hdir, 'project')
|
491
|
-
Dir.mkdir(@tmpdir)
|
492
|
-
Dir.chdir(@tmpdir) do
|
493
|
-
mk_symlink
|
494
|
-
# Timeout after 300 secs/5 mins.
|
495
|
-
Timeout.timeout(300) do
|
496
|
-
example.run
|
497
|
-
end
|
498
|
-
rm_symlink
|
499
|
-
end
|
500
|
-
end
|
501
|
-
ENV['HOME'] = saved_home
|
502
|
-
end
|
503
|
-
|
504
|
-
$exited_abnormally = false
|
505
|
-
end
|
506
|
-
end
|
507
|
-
|