|
| 1 | +--Copyright 2021 The casbin Authors. All Rights Reserved. |
| 2 | +-- |
| 3 | +--Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +--you may not use this file except in compliance with the License. |
| 5 | +--You may obtain a copy of the License at |
| 6 | +-- |
| 7 | +-- http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +-- |
| 9 | +--Unless required by applicable law or agreed to in writing, software |
| 10 | +--distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +--WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +--See the License for the specific language governing permissions and |
| 13 | +--limitations under the License. |
| 14 | + |
| 15 | +local log = require("src.util.Log") |
| 16 | +local path = os.getenv("PWD") or io.popen("cd"):read() |
| 17 | +path = path .. "/testLogFile.log" |
| 18 | + |
| 19 | +describe("log tests", function () |
| 20 | + |
| 21 | + it("test console logger", function () |
| 22 | + local logger = Log:getLogger() |
| 23 | + assert.has_no.errors(function () |
| 24 | + logger:info("logging to console") |
| 25 | + end) |
| 26 | + end) |
| 27 | + |
| 28 | + it("test file logger", function () |
| 29 | + local logger = Log:getFileLogger(path) |
| 30 | + logger:info("new log started") |
| 31 | + assert.has_no.errors(function () |
| 32 | + io.open(path, "r") |
| 33 | + end) |
| 34 | + end) |
| 35 | + |
| 36 | + it("test filePath error", function () |
| 37 | + assert.has_error(function () |
| 38 | + local logger = Log:getFileLogger() |
| 39 | + end) |
| 40 | + end) |
| 41 | +end) |
0 commit comments