Skip to content

Commit

Permalink
Add simple test for --line option
Browse files Browse the repository at this point in the history
  • Loading branch information
allie-wake-up committed Jan 5, 2023
1 parent 790f1a8 commit 28b88bb
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 20 deletions.
32 changes: 13 additions & 19 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,25 @@ env:
CARGO_TERM_COLOR: always

jobs:
test:
name: Test
runs-on: ubuntu-latest
build:
name: Build on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]

steps:
- uses: actions/checkout@v2
- name: Setup xcb
if: ${{ matrix.os == 'ubuntu-latest' }}
run: sudo apt-get install libxcb-xfixes0-dev
- name: Setup rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
components: rustfmt, clippy
- name: Setup gpg
if: ${{ matrix.os == 'ubuntu-latest' }}
run: |
echo "${{secrets.GPG_PUBLIC_KEY}}" | gpg --import
echo "${{secrets.GPG_PRIVATE_KEY}}" | gpg --import
Expand All @@ -31,21 +38,8 @@ jobs:
run: cargo clippy
- name: RustFmt
run: cargo fmt -- --check
- name: Run tests
run: cargo test --verbose

build:
name: Build on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]

steps:
- uses: actions/checkout@v2
- name: Setup rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
- name: Build
run: cargo build --verbose
- name: Run tests
if: ${{ matrix.os == 'ubuntu-latest' }}
run: cargo test --verbose
11 changes: 10 additions & 1 deletion src/show.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,16 @@ mod tests {
get_test_settings(),
)
.unwrap();
assert_eq!(String::from_utf8(result).unwrap().trim(), "test");
assert_eq!(String::from_utf8(result).unwrap().trim(), "test\nline2");
}

#[test]
fn print_password_line_2() {
let mut result: Vec<u8> = vec![];
let mut opts = Show::new(Some(String::from("test")));
opts.line = Some(2);
show(&mut result, opts, get_test_settings()).unwrap();
assert_eq!(String::from_utf8(result).unwrap().trim(), "line2");
}

#[test]
Expand Down
1 change: 1 addition & 0 deletions test-store/test.gpg
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
test
line2

0 comments on commit 28b88bb

Please sign in to comment.