Skip to content

Commit

Permalink
Fix specs to run on Crystal 0.31.0
Browse files Browse the repository at this point in the history
  • Loading branch information
j8r committed Sep 27, 2019
1 parent 229738d commit a71ac35
Show file tree
Hide file tree
Showing 14 changed files with 502 additions and 409 deletions.
118 changes: 109 additions & 9 deletions spec/cli_spec.cr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require "./spec_helper"
require "../src/cli"
require "./prefix_helper"
require "file_utils"

def install_dppm(prefix : String)
Expand All @@ -13,19 +13,73 @@ def install_dppm(prefix : String)
)
end

def build_package(prefix_path : String, package : String = TEST_APP_PACKAGE_NAME)
pkg = DPPM::CLI::Pkg.build(
no_confirm: true,
config: DPPM_CONFIG_FILE,
source_name: DPPM::Prefix.default_source_name,
source_path: SAMPLES_DIR,
prefix: prefix_path,
package: package,
custom_vars: Array(String).new)
pkg.name.starts_with?(TEST_APP_PACKAGE_NAME).should be_true
pkg.exists?.should eq pkg
end

def add_application(prefix_path : String, application : String = TEST_APP_PACKAGE_NAME, name : String = TEST_APP_PACKAGE_NAME, version : String? = nil)
app = DPPM::CLI::App.add(
no_confirm: true,
config: DPPM_CONFIG_FILE,
group: DPPM::Prefix.default_group,
source_name: DPPM::Prefix.default_source_name,
source_path: SAMPLES_DIR,
prefix: prefix_path,
application: application,
name: name,
version: version,
contained: false,
noservice: true,
socket: false)
app.name.starts_with?(TEST_APP_PACKAGE_NAME).should be_true
app.exists?.should eq app
end

def upgrade_application(prefix_path : String, version : String, application : String = TEST_APP_PACKAGE_NAME)
app = DPPM::CLI::App.upgrade(
no_confirm: true,
config: DPPM_CONFIG_FILE,
group: DPPM::Prefix.default_group,
source_name: DPPM::Prefix.default_source_name,
source_path: SAMPLES_DIR,
prefix: prefix_path,
application: application,
contained: false,
version: version,
)
app.pkg.version.should eq version
end

def delete_application(prefix_path : String, application : String = TEST_APP_PACKAGE_NAME)
app = DPPM::CLI::App.delete(
no_confirm: true,
prefix: prefix_path,
group: DPPM::Prefix.default_group,
application: application,
keep_user_group: false,
preserve_database: false).not_nil!
app.name.should eq application
app.exists?.should be_nil
end

describe DPPM::CLI do
it "installs DPPM" do
prefix = spec_root_prefix
begin
spec_with_tempdir do |prefix|
install_dppm prefix
ensure
FileUtils.rm_rf prefix
end
end

it "uninstalls DPPM" do
prefix = spec_root_prefix
begin
spec_with_tempdir do |prefix|
install_dppm prefix

DPPM::CLI.uninstall_dppm(
Expand All @@ -36,8 +90,54 @@ describe DPPM::CLI do
source_name: DPPM::Prefix.default_source_name,
source_path: nil
)
ensure
FileUtils.rm_rf prefix
end
end

describe DPPM::CLI::Pkg do
it "cleans unused packages" do
spec_with_prefix do |prefix|
build_package prefix.path.to_s
Dir.rmdir (prefix.app / "dppm").to_s
packages = prefix.clean_unused_packages(false) { }
packages.not_nil!.should eq Set{"libfake_0.0.1", "testapp_0.2.0"}
Dir.children(prefix.pkg.to_s).should be_empty
end
end

it "builds a packages" do
spec_with_prefix do |prefix|
build_package prefix.path.to_s
end
end
end

describe DPPM::CLI::App do
it "adds an application with a version and no package built" do
spec_with_prefix do |prefix|
add_application prefix_path: prefix.path.to_s, version: "0.3.0"
delete_application prefix.path.to_s
end
end

it "adds an application" do
spec_with_prefix do |prefix|
add_application prefix_path: prefix.path.to_s
end
end

it "upgrades an application" do
spec_with_prefix do |prefix|
add_application prefix_path: prefix.path.to_s
upgrade_application prefix_path: prefix.path.to_s, version: "0.3.0"
delete_application prefix.path.to_s
end
end

it "deletes an application" do
spec_with_prefix do |prefix|
add_application prefix_path: prefix.path.to_s
delete_application prefix.path.to_s
end
end
end
end
1 change: 1 addition & 0 deletions spec/config/format_spec.cr
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
require "spec"
require "../../src/config/format"

module Config::Format
Expand Down
61 changes: 0 additions & 61 deletions spec/integration/cli_prefix_spec.cr

This file was deleted.

75 changes: 0 additions & 75 deletions spec/integration/prefix_spec.cr

This file was deleted.

40 changes: 0 additions & 40 deletions spec/integration_spec.cr

This file was deleted.

Loading

0 comments on commit a71ac35

Please sign in to comment.