From f949872a24ac1ab6d9a542a393ea590990740806 Mon Sep 17 00:00:00 2001 From: Pete Freitag Date: Fri, 6 Oct 2017 22:29:19 -0400 Subject: [PATCH 1/2] Fixed TestCore and TestFactory --- tests/resourcesError/ErrorMember.cfc | 3 +++ tests/tests/TestCore.cfc | 10 +++++----- tests/tests/TestFactory.cfc | 3 ++- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/tests/resourcesError/ErrorMember.cfc b/tests/resourcesError/ErrorMember.cfc index 4bf27e79..6fb52598 100644 --- a/tests/resourcesError/ErrorMember.cfc +++ b/tests/resourcesError/ErrorMember.cfc @@ -1,2 +1,5 @@ + + + \ No newline at end of file diff --git a/tests/tests/TestCore.cfc b/tests/tests/TestCore.cfc index 28ddc243..2de502b7 100644 --- a/tests/tests/TestCore.cfc +++ b/tests/tests/TestCore.cfc @@ -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."); } @@ -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"); @@ -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")); diff --git a/tests/tests/TestFactory.cfc b/tests/tests/TestFactory.cfc index c44d1f3a..a0853ebd 100644 --- a/tests/tests/TestFactory.cfc +++ b/tests/tests/TestFactory.cfc @@ -2,6 +2,7 @@ function beforeTests(){ + request["_testsRunning"] = true; variables.taffy = createObject("component","taffy.tests.Application"); makePublic(variables.taffy, "getBeanFactory"); variables.factory = variables.taffy.getBeanFactory(); @@ -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 ); } From 0cc0d34d7df8c71619ca425ca94b0c6b566759c9 Mon Sep 17 00:00:00 2001 From: Pete Freitag Date: Fri, 6 Oct 2017 23:10:39 -0400 Subject: [PATCH 2/2] Fixed test_hoth --- .gitignore | 1 + box.json | 6 ++++-- tests/tests/Application.cfc | 3 +++ tests/tests/TestLoggers.cfc | 17 +++++++++++------ 4 files changed, 19 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index cbd560ef..3df40985 100644 --- a/.gitignore +++ b/.gitignore @@ -13,6 +13,7 @@ css/* #testbox tests/testbox di1/ +hoth/ ### Intellij ### # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm diff --git a/box.json b/box.json index 4ca2dd98..c3f6f299 100644 --- a/box.json +++ b/box.json @@ -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/" } } \ No newline at end of file diff --git a/tests/tests/Application.cfc b/tests/tests/Application.cfc index b5e505bb..86f6db21 100644 --- a/tests/tests/Application.cfc +++ b/tests/tests/Application.cfc @@ -4,6 +4,9 @@ + + + diff --git a/tests/tests/TestLoggers.cfc b/tests/tests/TestLoggers.cfc index e90054ba..c0f766d6 100644 --- a/tests/tests/TestLoggers.cfc +++ b/tests/tests/TestLoggers.cfc @@ -2,13 +2,13 @@ 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", @@ -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(){