Navigation Menu

Skip to content

Commit

Permalink
adds tests for
Browse files Browse the repository at this point in the history
  • Loading branch information
chapmandu committed Jul 28, 2016
1 parent f1c4155 commit fe63a7e
Show file tree
Hide file tree
Showing 3 changed files with 161 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -11,3 +11,4 @@ WEB-INF
/subfolder/
/bin/
server.json
cfwheels.*.zip
8 changes: 7 additions & 1 deletion wheels/global/internal.cfm
Expand Up @@ -1192,6 +1192,7 @@ public string function $buildReleaseZip(
];
// directories & files to be removed
// TOOD: also filter out crap like .DS_Store
loc.exclude = [
"wheels/tests",
"wheels/public/build.cfm"
Expand All @@ -1205,7 +1206,12 @@ public string function $buildReleaseZip(
$zip(file=loc.path, source=ExpandPath(loc.i));
} else if (DirectoryExists(ExpandPath(loc.i))) {
$zip(file=loc.path, source=ExpandPath(loc.i), prefix=loc.i);
// TODO: throw if file/dir not found
} else {
throw(
type="Wheels.Build",
message="#ExpandPath(loc.i)# not found",
detail="All paths specified in loc.include must exist"
);
}
};
for (loc.i in loc.exclude) {
Expand Down
153 changes: 153 additions & 0 deletions wheels/tests/global/internal/$buildreleasezip.cfc
@@ -0,0 +1,153 @@
component extends="wheels.tests.Test" {

function packageSetup() {
loc.path = $buildReleaseZip(version="6.6.6");
$zip(action="list", name="loc.list", file=loc.path);
}

function packageTeardown() {
if (FileExists(loc.path)) {
fileDelete(loc.path);
}
}

function test_$buildreleasezip_contains_config_directory() {
loc.actual = $filesInDirectory("config");
debug("loc.actual", false);
debug("loc.list", false);
assert("loc.actual.recordCount eq 9");
}

function test_$buildreleasezip_contains_controllers_directory() {
loc.actual = $filesInDirectory("controllers");
debug("loc.actual", false);
assert("loc.actual.recordCount eq 2");
}

function test_$buildreleasezip_contains_events_directory() {
loc.actual = $filesInDirectory("events");
debug("loc.actual", false);
assert("loc.actual.recordCount eq 10");
}

function test_$buildreleasezip_contains_files_directory() {
loc.actual = $filesInDirectory("files");
debug("loc.actual", false);
assert("loc.actual.recordCount eq 1");
}

function test_$buildreleasezip_contains_images_directory() {
loc.actual = $filesInDirectory("images");
debug("loc.actual", false);
assert("loc.actual.recordCount eq 1");
}

function test_$buildreleasezip_contains_javascripts_directory() {
loc.actual = $filesInDirectory("javascripts");
debug("loc.actual", false);
assert("loc.actual.recordCount eq 1");
}

function test_$buildreleasezip_contains_miscellaneous_directory() {
loc.actual = $filesInDirectory("miscellaneous");
debug("loc.actual", false);
assert("loc.actual.recordCount eq 1");
}

function test_$buildreleasezip_contains_models_directory() {
loc.actual = $filesInDirectory("models");
debug("loc.actual", false);
assert("loc.actual.recordCount eq 2");
}

function test_$buildreleasezip_contains_plugins_directory() {
loc.actual = $filesInDirectory("plugins");
debug("loc.actual", false);
assert("loc.actual.recordCount eq 1");
}

function test_$buildreleasezip_contains_stylesheets_directory() {
loc.actual = $filesInDirectory("stylesheets");
debug("loc.actual", false);
assert("loc.actual.recordCount eq 1");
}

function test_$buildreleasezip_contains_tests_directory() {
loc.actual = $filesInDirectory("tests");
debug("loc.actual", false);
assert("loc.actual.recordCount eq 6");
}

function test_$buildreleasezip_contains_views_directory() {
loc.actual = $filesInDirectory("views");
debug("loc.actual", false);
assert("loc.actual.recordCount eq 4");
}

function test_$buildreleasezip_contains_wheels_directory() {
loc.actual = $filesInDirectory("wheels");
debug("loc.actual", false);
// TODO: how best to evaluate the wheels dir?
assert("loc.actual.recordCount gt 90");
}

function test_$buildreleasezip_contains_commandbox_server_files() {
loc.actual = queryExecute("
SELECT *
FROM loc.list
WHERE name LIKE 'server-%' AND name LIKE '%.json'
",
[],
{dbtype = "query"}
);
debug("loc.actual", false);
assert("loc.actual.recordCount eq 5");
}

function test_$buildreleasezip_contains_files_in_root() {
loc.actual = queryExecute("
SELECT *
FROM loc.list
WHERE name IN (
'web.config',
'urlrewrite.xml',
'root.cfm',
'rewrite.cfm',
'README.md',
'IsapiRewrite4.ini',
'index.cfm',
'Application.cfc',
'.htaccess'
)
",
[],
{dbtype = "query"}
);
debug("loc.actual", false);
assert("loc.actual.recordCount eq 9");
}

function test_$buildreleasezip_contains_no_additional_file_in_root() {
loc.actual = queryExecute("
SELECT *
FROM loc.list
WHERE directory = ''
",
[],
{dbtype = "query"}
);
debug("loc.actual", false);
assert("loc.actual.recordCount eq 14");
}

private query function $filesInDirectory(required string directory) {
return queryExecute("
SELECT *
FROM loc.list
WHERE directory LIKE '#arguments.directory#%'
",
[],
{dbtype = "query"}
);
}
}

0 comments on commit fe63a7e

Please sign in to comment.