-
Notifications
You must be signed in to change notification settings - Fork 1
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 #29 from LuisLiraC/chore/tests-mod
Chore/tests mod
- Loading branch information
Showing
9 changed files
with
221 additions
and
158 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 |
---|---|---|
@@ -0,0 +1,54 @@ | ||
name: Clippy Test | ||
|
||
on: | ||
pull_request: | ||
|
||
|
||
jobs: | ||
git-diff: | ||
runs-on: ubuntu-latest | ||
name: 'Git Diff - Powered by Rust' | ||
outputs: | ||
DIFF_FILES: ${{ steps.git-diff.outputs.DIFF_FILES }} | ||
DIFF_COUNT: ${{ steps.git-diff.outputs.DIFF_COUNT }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: LuisLiraC/[email protected] | ||
id: git-diff | ||
with: | ||
patterns: '*.rs' | ||
|
||
clippy-test: | ||
runs-on: ubuntu-latest | ||
needs: [git-diff] | ||
if: ${{ needs.git-diff.outputs.DIFF_COUNT != 0 }} | ||
name: Run Tests | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Cache cargo registry | ||
uses: actions/cache@v4 | ||
with: | ||
path: ~/.cargo/registry | ||
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} | ||
restore-keys: | | ||
${{ runner.os }}-cargo-registry- | ||
- name: Cache cargo index | ||
uses: actions/cache@v4 | ||
with: | ||
path: ~/.cargo/git | ||
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }} | ||
restore-keys: | | ||
${{ runner.os }}-cargo-index- | ||
- name: Cache cargo build | ||
uses: actions/cache@v4 | ||
with: | ||
path: target | ||
key: ${{ runner.os }}-cargo-build-${{ hashFiles('**/Cargo.lock') }} | ||
restore-keys: | | ||
${{ runner.os }}-cargo-build- | ||
- name: Run Tests | ||
run: cargo clippy --color always -- -Dwarnings -W clippy::pedantic |
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
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
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 |
---|---|---|
|
@@ -5,8 +5,23 @@ on: | |
|
||
|
||
jobs: | ||
git-diff: | ||
runs-on: ubuntu-latest | ||
name: 'Git Diff - Powered by Rust' | ||
outputs: | ||
DIFF_FILES: ${{ steps.git-diff.outputs.DIFF_FILES }} | ||
DIFF_COUNT: ${{ steps.git-diff.outputs.DIFF_COUNT }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: LuisLiraC/[email protected] | ||
id: git-diff | ||
with: | ||
patterns: '*.rs' | ||
|
||
test: | ||
runs-on: ubuntu-latest | ||
needs: [git-diff] | ||
if: ${{ needs.git-diff.outputs.DIFF_COUNT != 0 }} | ||
name: Run Tests | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
@@ -36,4 +51,4 @@ jobs: | |
${{ runner.os }}-cargo-build- | ||
- name: Run Tests | ||
run: cargo test | ||
run: cargo test --color always |
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
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
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,32 +1,29 @@ | ||
use crate::*; | ||
|
||
#[cfg(test)] | ||
mod integration { | ||
use super::*; | ||
|
||
#[test] | ||
fn test_filter() { | ||
let arg = "--patterns=*.rs,!*..txt"; | ||
let files = vec![ | ||
String::from("src/main.rs"), | ||
String::from("lib.rs"), | ||
String::from("test.txt"), | ||
]; | ||
#[test] | ||
fn test_filter() { | ||
let arg = "--patterns=*.rs,!*..txt"; | ||
let files = vec![ | ||
String::from("src/main.rs"), | ||
String::from("lib.rs"), | ||
String::from("test.txt"), | ||
]; | ||
|
||
let filters = create_patterns_filters(arg); | ||
let filters = create_patterns_filters(arg); | ||
|
||
let (include_patterns_filters, exclude_patterns_filters) = categorize_filters(filters); | ||
let (include_patterns_filters, exclude_patterns_filters) = categorize_filters(&filters); | ||
|
||
let filtered_files = filter_files(files, include_patterns_filters, exclude_patterns_filters); | ||
let filtered_files = filter_files(&files, &include_patterns_filters, &exclude_patterns_filters); | ||
|
||
let count = get_count(filtered_files.clone()); | ||
let count = get_count(&filtered_files); | ||
|
||
let expected_filtered_files = HashSet::from([ | ||
String::from("src/main.rs"), | ||
String::from("lib.rs"), | ||
]); | ||
let expected_filtered_files = HashSet::from([ | ||
String::from("src/main.rs"), | ||
String::from("lib.rs"), | ||
]); | ||
|
||
assert_eq!(filtered_files, expected_filtered_files); | ||
assert_eq!(count, 2); | ||
} | ||
assert_eq!(filtered_files, expected_filtered_files); | ||
assert_eq!(count, 2); | ||
} |
Oops, something went wrong.