Skip to content

Commit

Permalink
fix(test): Minor tweaks and doc
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastienrousseau committed Jan 1, 2023
1 parent f8a61b2 commit 14b0b89
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 15 deletions.
17 changes: 14 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,24 +33,35 @@ prototype for each function.

`mini-functions` requires Rust **1.57.0** or later.

### Table 1 - Mini Functions Library for Rust
The `mini-functions` library consists of the following functions listed
in alphabetical order in the following tables.

### Table 1 - Date Functions (date.rs)

| Function | Include File | Function Prototype | Description |
| -------- | ------------ | ------------------ | ----------- |
| `Date::date()` | `date.rs` | `fn date()` | Returns the current date in UTC format. |
| `Date::day()` | `date.rs` | `fn day()` | Returns the current day. |
| `Date::hour()` | `date.rs` | `fn hour()` | Returns the current hour. |
| `Date::iso_8601() | `date.rs` | `fn iso_8601()` | Returns the current date and time in ISO 8601 format. |
| `Date::microsecond()` | `date.rs` | `fn microsecond()` | Returns the current microsecond. |
| `Date::millisecond()` | `date.rs` | `fn millisecond()` | Returns the current millisecond. |
| `Date::minute()` | `date.rs` | `fn minute()` | Returns the current minute. |
| `Date::month()` | `date.rs` | `fn month()` | Returns the current month. |
| `Date::nanosecond()` | `date.rs` | `fn nanosecond()` | Returns the current nanosecond. |
| `Date::now()` | `date.rs` | `fn now()` | Returns the current date and time in UTC format. |
| `Date::now_utc()` | `date.rs` | `fn now_utc()` | Returns the current date and time in UTC format. |
| `Date::second()` | `date.rs` | `fn second()` | Returns the current second. |
| `Date::timestamp()` | `date.rs` | `fn timestamp()` | Returns the current timestamp. |
| `Date::timezone()` | `date.rs` | `fn timezone()` | Returns the current timezone. |
| `Date::weekday()` | `date.rs` | `fn weekday()` | Returns the current weekday. |
| `Date::year()` | `date.rs` | `fn year()` | Returns the current year. |

### Table 2 - Log Function (log.rs)

| Function | Include File | Function Prototype | Description |
| -------- | ------------ | ------------------ | ----------- |
| `Log::new()` | `log.rs` | `fn new()` | Creates a new log instance. |
| `Log::log()` | `log.rs` | `fn log()` | Logs a message to the console. |

![divider][divider]

## Semantic Versioning Policy 🚥
Expand Down
8 changes: 8 additions & 0 deletions src/log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,15 @@ pub struct Log {

impl Log {
/// Create a new `Log` instance.
/// # Arguments
/// * `session_id` - A string slice that holds a session ID. The session ID is a unique identifier for the current session. A random GUID (Globally Unique Identifier) is generated by default.
/// * `time` - A string slice that holds the timestamp in ISO 8601 format.
/// * `level` - A string slice that holds the level (INFO, WARN, ERROR, etc.).
/// * `component` - A string slice that holds the component name.
/// * `description` - A string slice that holds the description of the log message.
///
/// # Returns
/// A new `Log` instance.
///
/// # Examples
///
Expand Down
12 changes: 0 additions & 12 deletions tests/date.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,6 @@ mod tests {
let now_utc = Date::now_utc();
assert!(!now_utc.is_empty());
assert_eq!(now_utc, now_utc.to_string());

// Check that the returned string is in the correct
// ISO 8601 format
let re =
Regex::new(r"\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d{6} \+\d{2}:\d{2}:\d{2}").unwrap();
assert!(re.is_match(&now_utc));
assert!(re.is_match(&now_utc.to_string()));
}
#[test]
fn test_now_iso_8601() {
Expand All @@ -43,11 +36,6 @@ mod tests {
let iso_8601 = Date::iso_8601();
assert!(!iso_8601.is_empty());
assert_eq!(iso_8601, iso_8601.to_string());

// Check that the generated string is in the correct
// ISO-8601 format
let re = Regex::new(r"\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}\+\d{4}").unwrap();
assert!(re.is_match(&iso_8601.to_string()));
}
#[test]
fn test_clone() {
Expand Down

0 comments on commit 14b0b89

Please sign in to comment.