Skip to content

Commit

Permalink
Merge pull request #352 from pfreitag/master
Browse files Browse the repository at this point in the history
Fixed TestCore and TestFactory
  • Loading branch information
atuttle committed Oct 7, 2017
2 parents 0860195 + 0cc0d34 commit 2343740
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 14 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -13,6 +13,7 @@ css/*
#testbox
tests/testbox
di1/
hoth/

### Intellij ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm
Expand Down
6 changes: 4 additions & 2 deletions box.json
Expand Up @@ -14,10 +14,12 @@
"devDependencies":{
"testbox":"^2.5.0+107",
"commandbox-cfconfig":"be",
"di1":"git+https://github.com/framework-one/di1.git"
"di1":"git+https://github.com/framework-one/di1.git",
"hoth":"git+https://github.com/aarongreenlee/Hoth.git"
},
"installPaths":{
"testbox":"tests/testbox/",
"di1":"di1"
"di1":"tests/di1",
"Hoth":"tests/Hoth/"
}
}
3 changes: 3 additions & 0 deletions tests/resourcesError/ErrorMember.cfc
@@ -1,2 +1,5 @@
<cfcomponent extends="taffy.core.resource">
<cfif structKeyExists(request, "_testsRunning")>
<cfthrow message="Fail">
</cfif>
</cfcomponent>
3 changes: 3 additions & 0 deletions tests/tests/Application.cfc
Expand Up @@ -4,6 +4,9 @@

<cfset this.mappings["/mxunit"] = expandPath("../testbox/system/compat/")>
<cfset this.mappings["/testbox"] = expandPath("../testbox/")>
<cfset this.mappings["/Hoth"] = expandPath("../Hoth/")>
<cfset this.mappings["/di1"] = expandPath("../di1/")>


<cffunction name="onRequestStart" returnType="void" access="public" output="false">
<cfif NOT isDefined('application._taffy')>
Expand Down
10 changes: 5 additions & 5 deletions tests/tests/TestCore.cfc
Expand Up @@ -283,8 +283,8 @@
}

function test_external_file_request_passes_through(){
local.result = getUrl('http://#CGI.SERVER_NAME#:#CGI.SERVER_PORT#/taffy/tests/someFolder/someOtherFile.cfm');
// debug(local.result);
local.result = getUrl('http://#CGI.SERVER_NAME#:#CGI.SERVER_PORT##replace(cgi.script_name, "/tests/tests/run.cfm", "/tests/someFolder/someOtherFile.cfm")#');
debug(local.result);
assertTrue(findNoCase('woot', local.result.fileContent), "Was not able to get the DMZ file.");
}

Expand Down Expand Up @@ -528,9 +528,9 @@
function test_properly_handles_arbitrary_cors_headers(){
//see: https://github.com/atuttle/Taffy/issues/144
application._taffy.settings.allowCrossDomain = true;
local.h = { "Access-Control-Request-Headers" = "goat, pigeon, man-bear-pig"};
local.h = { "Access-Control-Request-Headers" = "goat, pigeon, man-bear-pig", "Origin":"http://#cgi.server_name#/"};
local.result = apiCall("get", "/echo/dude.json", "", local.h);
// debug(local.result);
//debug(local.result);
assertTrue(local.result.responseHeader["Access-Control-Allow-Headers"] contains "goat");
assertTrue(local.result.responseHeader["Access-Control-Allow-Headers"] contains "pigeon");
assertTrue(local.result.responseHeader["Access-Control-Allow-Headers"] contains "man-bear-pig");
Expand All @@ -539,7 +539,7 @@
function test_properly_handles_arbitrary_cors_headers_on_error(){
//see: https://github.com/atuttle/Taffy/issues/159
application._taffy.settings.allowCrossDomain = true;
local.h = { "Access-Control-Request-Headers" = "goat, pigeon, man-bear-pig"};
local.h = { "Access-Control-Request-Headers" = "goat, pigeon, man-bear-pig", "Origin":"http://#cgi.server_name#/"};
local.result = apiCall("get", "/throwException.json", "", local.h);
// debug(local.result);
assertTrue(structKeyExists(local.result.responseHeader, "Access-Control-Allow-Origin"));
Expand Down
3 changes: 2 additions & 1 deletion tests/tests/TestFactory.cfc
Expand Up @@ -2,6 +2,7 @@
<cfscript>

function beforeTests(){
request["_testsRunning"] = true;
variables.taffy = createObject("component","taffy.tests.Application");
makePublic(variables.taffy, "getBeanFactory");
variables.factory = variables.taffy.getBeanFactory();
Expand Down Expand Up @@ -61,7 +62,7 @@

function test_lists_skipped_resources(){
variables.factory.loadBeansFromPath( expandPath('/taffy/tests/resourcesError'), 'taffy.tests.resourcesError', expandPath('/taffy/tests/resourcesError'), true, variables.taffy);
// debug(variables.taffy.status);
debug(variables.taffy.status);
assertTrue(structKeyExists(variables.taffy.status, "skippedResources"));
assertTrue( arrayLen(variables.taffy.status.skippedResources) gt 0 );
}
Expand Down
17 changes: 11 additions & 6 deletions tests/tests/TestLoggers.cfc
Expand Up @@ -2,13 +2,13 @@
<cfscript>

function test_hoth(){
var mockHoth = mock();
var mockHoth = getMockBox().createMock(className="Hoth.HothTracker", callLogging=true);
var hothAdapter = '';
var fakeError = {};

var callLog = {};
//setup the behaviors we're expecting the adapter to run
mockHoth.track('{struct}');

//mockHoth.track('{struct}');
mockHoth.$('track', true);
//create hoth adapter to test
hothAdapter = createObject("component", "taffy.bonus.LogToHoth").init(
"taffy.examples.api_hoth.resources.HothConfig",
Expand All @@ -19,8 +19,13 @@
fakeError.message = "This is a test error";
fakeError.detail = "Rubber Baby Buggy Bumper";
hothAdapter.saveLog(fakeError);

mockHoth.verify().track('{struct}');

callLog = mockHoth.$callLog();
debug(callLog);
assertTrue(structKeyExists(callLog, "track"), "should call track method");
assertTrue(isStruct(callLog.track[1][1]), "args should be a struct");
assertEquals(callLog.track[1][1].message, fakeError.message);

}

function test_BugLogHQ(){
Expand Down

0 comments on commit 2343740

Please sign in to comment.