-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from mcatta/chore/code-optimization
chore/code optimization
- Loading branch information
Showing
6 changed files
with
261 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
name: Shuttle Deploy | ||
name: Deploy | ||
|
||
on: | ||
push: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
name: Test | ||
|
||
on: | ||
push: | ||
branches: [ '*' ] | ||
|
||
env: | ||
CARGO_TERM_COLOR: always | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Build | ||
run: cargo build --verbose | ||
- name: Run tests | ||
run: cargo test --verbose |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
pub mod base64 { | ||
use anyhow::Error; | ||
use base64::{engine::general_purpose, Engine}; | ||
|
||
pub fn encode(input: &[u8]) -> String { | ||
general_purpose::STANDARD_NO_PAD.encode(input) | ||
} | ||
|
||
pub fn decode(input: &str) -> Result<Vec<u8>, Error> { | ||
general_purpose::STANDARD_NO_PAD.decode(input) | ||
.map_err(|_| Error::msg("Error on decoding")) | ||
} | ||
} | ||
|
||
mod hasher_tess { | ||
use crate::hasher; | ||
|
||
#[test] | ||
fn test_base64_encode() { | ||
// Given | ||
let input = "Hello World!"; | ||
|
||
// When | ||
let result = hasher::base64::encode(input.as_bytes()); | ||
|
||
// Then | ||
assert_eq!(result, "SGVsbG8gV29ybGQh"); | ||
} | ||
|
||
#[test] | ||
fn test_base64_decode() { | ||
// Given | ||
let input = "SGVsbG8gV29ybGQh"; | ||
|
||
// When | ||
let result = hasher::base64::decode(input).unwrap(); | ||
|
||
// Then | ||
assert_eq!(result, "Hello World!".as_bytes()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.