Fixed loading package in reinstall.
This commit is contained in:
parent
5e87eb438b
commit
d239db634e
2 changed files with 59 additions and 17 deletions
|
@ -255,15 +255,16 @@ returns
|
||||||
name: package_db.name,
|
name: package_db.name,
|
||||||
version: package_db.version,
|
version: package_db.version,
|
||||||
migration_not_down: true,
|
migration_not_down: true,
|
||||||
|
reinstall: data[:reinstall],
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
# store package
|
# store package
|
||||||
record = Package.create(meta)
|
|
||||||
if !data[:reinstall]
|
if !data[:reinstall]
|
||||||
|
package_db = Package.create(meta)
|
||||||
Store.add(
|
Store.add(
|
||||||
object: 'Package',
|
object: 'Package',
|
||||||
o_id: record.id,
|
o_id: package_db.id,
|
||||||
data: package.to_json,
|
data: package.to_json,
|
||||||
filename: "#{meta[:name]}-#{meta[:version]}.zpm",
|
filename: "#{meta[:name]}-#{meta[:version]}.zpm",
|
||||||
preferences: {},
|
preferences: {},
|
||||||
|
@ -279,15 +280,15 @@ returns
|
||||||
}
|
}
|
||||||
|
|
||||||
# update package state
|
# update package state
|
||||||
record.state = 'installed'
|
package_db.state = 'installed'
|
||||||
record.save
|
package_db.save
|
||||||
|
|
||||||
# up migrations
|
# up migrations
|
||||||
Package::Migration.migrate(meta[:name])
|
Package::Migration.migrate(meta[:name])
|
||||||
|
|
||||||
# prebuild assets
|
# prebuild assets
|
||||||
|
|
||||||
record
|
package_db
|
||||||
end
|
end
|
||||||
|
|
||||||
=begin
|
=begin
|
||||||
|
@ -307,7 +308,6 @@ returns
|
||||||
if !package
|
if !package
|
||||||
fail "No such package '#{package_name}'"
|
fail "No such package '#{package_name}'"
|
||||||
end
|
end
|
||||||
|
|
||||||
file = _get_bin(package.name, package.version)
|
file = _get_bin(package.name, package.version)
|
||||||
install(string: file, reinstall: true)
|
install(string: file, reinstall: true)
|
||||||
package
|
package
|
||||||
|
@ -350,11 +350,13 @@ returns
|
||||||
}
|
}
|
||||||
|
|
||||||
# delete package
|
# delete package
|
||||||
|
if !data[:reinstall]
|
||||||
record = Package.find_by(
|
record = Package.find_by(
|
||||||
name: package['name'],
|
name: package['name'],
|
||||||
version: package['version'],
|
version: package['version'],
|
||||||
)
|
)
|
||||||
record.destroy
|
record.destroy
|
||||||
|
end
|
||||||
|
|
||||||
record
|
record
|
||||||
end
|
end
|
||||||
|
|
|
@ -61,7 +61,34 @@ class PackageTest < ActiveSupport::TestCase
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
# test 2 - try to install same package again / should not work
|
# test 2 - renstall
|
||||||
|
{
|
||||||
|
action: 'reinstall',
|
||||||
|
name: 'UnitTestSample',
|
||||||
|
result: true,
|
||||||
|
verify: {
|
||||||
|
package: {
|
||||||
|
name: 'UnitTestSample',
|
||||||
|
version: '1.0.1',
|
||||||
|
},
|
||||||
|
check_files: [
|
||||||
|
{
|
||||||
|
location: 'test.txt',
|
||||||
|
result: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
location: 'test2.txt',
|
||||||
|
result: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
location: 'some/dir/test.txt',
|
||||||
|
result: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
# test 3 - try to install same package again / should not work
|
||||||
{
|
{
|
||||||
zpm: '{
|
zpm: '{
|
||||||
"name": "UnitTestSample",
|
"name": "UnitTestSample",
|
||||||
|
@ -87,7 +114,7 @@ class PackageTest < ActiveSupport::TestCase
|
||||||
result: false,
|
result: false,
|
||||||
},
|
},
|
||||||
|
|
||||||
# test 3 - try to install lower version / should not work
|
# test 4 - try to install lower version / should not work
|
||||||
{
|
{
|
||||||
zpm: '{
|
zpm: '{
|
||||||
"name": "UnitTestSample",
|
"name": "UnitTestSample",
|
||||||
|
@ -113,7 +140,7 @@ class PackageTest < ActiveSupport::TestCase
|
||||||
result: false,
|
result: false,
|
||||||
},
|
},
|
||||||
|
|
||||||
# test 4 - upgrade 7 should work
|
# test 5 - upgrade 7 should work
|
||||||
{
|
{
|
||||||
zpm: '{
|
zpm: '{
|
||||||
"name": "UnitTestSample",
|
"name": "UnitTestSample",
|
||||||
|
@ -173,7 +200,7 @@ class PackageTest < ActiveSupport::TestCase
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
# test 4 - uninstall package / should work
|
# test 6 - uninstall package / should work
|
||||||
{
|
{
|
||||||
name: 'UnitTestSample',
|
name: 'UnitTestSample',
|
||||||
version: '1.0.2',
|
version: '1.0.2',
|
||||||
|
@ -193,7 +220,7 @@ class PackageTest < ActiveSupport::TestCase
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
# test 5 - check auto_install mechanism
|
# test 7 - check auto_install mechanism
|
||||||
{
|
{
|
||||||
zpm: '{
|
zpm: '{
|
||||||
"name": "UnitTestSample",
|
"name": "UnitTestSample",
|
||||||
|
@ -253,7 +280,7 @@ class PackageTest < ActiveSupport::TestCase
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
# test 6 - check uninstall / should work
|
# test 8 - check uninstall / should work
|
||||||
{
|
{
|
||||||
name: 'UnitTestSample',
|
name: 'UnitTestSample',
|
||||||
version: '1.0.2',
|
version: '1.0.2',
|
||||||
|
@ -288,6 +315,19 @@ class PackageTest < ActiveSupport::TestCase
|
||||||
else
|
else
|
||||||
assert( !package, 'install package successful but should not' )
|
assert( !package, 'install package successful but should not' )
|
||||||
end
|
end
|
||||||
|
elsif test[:action] == 'reinstall'
|
||||||
|
begin
|
||||||
|
package = Package.reinstall( test[:name] )
|
||||||
|
rescue
|
||||||
|
package = false
|
||||||
|
end
|
||||||
|
if test[:result]
|
||||||
|
assert( package, 'reinstall package not successful' )
|
||||||
|
issues = package.verify
|
||||||
|
assert( !issues, 'package verify not successful' )
|
||||||
|
else
|
||||||
|
assert( !package, 'reinstall package successful but should not' )
|
||||||
|
end
|
||||||
elsif test[:action] == 'uninstall'
|
elsif test[:action] == 'uninstall'
|
||||||
if test[:zpm]
|
if test[:zpm]
|
||||||
begin
|
begin
|
||||||
|
|
Loading…
Reference in a new issue