summaryrefslogtreecommitdiffhomepage
path: root/utils
AgeCommit message (Collapse)Author
2017-02-21utils: Use local loggerBjørn Erik Pedersen
2016-03-23utils: Add godocBjørn Erik Pedersen
2016-03-21Utils methods refactored for readabilitysrinivasreddy
2015-12-10Add copyright header to that source files that don’t have one.Anthony Fok
See #1646
2015-10-05Let Cobra do the usage error loggingBjørn Erik Pedersen
Fixes #1472
2015-09-13Complete the Url-to-URL transition in testsAnthony Fok
See #959
2015-03-05Apply gofmt -sbep
2015-02-17Revert "Expansion of unit tests for utils/utils.go"Anthony Fok
Rationale: Test failing on Windows with errors like this: utils_test.go:177: Error: Could not remove file "f". Error: remove C:\Users\appveyor\AppData\Local\Temp\utils_test_747965610: The process cannot access the file because it is being used by another process. This reverts commit 6b28e38cea0dec3e3f045ab8ec833608b91a946f. Sorry for my premature merge of Pull Request #818.
2015-02-17Expansion of unit tests for utils/utils.goOwen Waller
This commit expands the test coverage for the utils/utils.go module. The utils module uses the 'github.com/spf13/jwalterweatherman' (aka jww) package for logging. The tests take the approach of examining the log file that is produced by this module to verify correct behaviour. This avoids refactoring the utils module. The log file messages written by the jww module are of the form: <log level>: yyyy/mm/dd <string|error message> The checkLogFile function checks each of these parts in turn except for the date string, which is currently ignored. The final part of the log file format can either be a single error message, or a series of strings followed by an error message. Both the error message and the series of strings can be empty strings. The log file is checked using a combination of the regex package, along with the bufio scanner type. Each test logs to its own temporary log file. This is achieved with standard test setup and teardown functions. One consequence of these tests is that StopOnErr has been refactored into call a new unexported function doStopOnErr which contains the bulk of the original logic. This allows the same testing approach to be used with StopOnErr as with CheckErr and cutUsageMessage, rather than look at the exit status code of the test itself. An unfortunate side effect of this is that the author of the tests must now know if a log file is expected or not. If doStopOnErr determines that an empty error message would be written to the log file then nothing is written. In the context of the tests this means that the log file created by the test would have no contents. Consequently there would be nothing for the test to examine. This situation is indicated by the boolean flag logFileExoected in the testData struct, and processed by the logFileIsExpectedAndValid function. Although not ideal this was deemed a reasonable compromise.
2014-09-08More error messages at syncing static contentsTatsushi Demachi
2014-08-25added functionality to check the error message returned from Cobra, if any. ↵Joel Scoble
for uage message text. If its present, the usage message gets truncated and the resulting message is returned to be used for the rest of the error message. If the resulting error is blank, no error message is printed
2014-06-30report errorsBillie H. Cleek
Modify CheckErr and StopOnErrErr to report the error if there aren't any other messages.
2014-03-31Adding support for logging & verbose logging. Consolidation of error ↵spf13
handling. Integration of jWalterWeatherman library. Fixed #137
2013-10-09simplified buildSite & better error handling around itspf13
2013-10-09Clean up server & build site logic. Fixed #94spf13