Skip to content

Commit

Permalink
test(add): add some test case to test codecov
Browse files Browse the repository at this point in the history
  • Loading branch information
phnaharris committed Dec 17, 2023
1 parent e24d109 commit 542b867
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 7 deletions.
45 changes: 41 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,47 @@ on:
branches: [main]
name: main
jobs:
codecov:
test:
name: Test Suite
runs-on: ubuntu-latest

steps:
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
- name: Checkout sources
uses: actions/checkout@v2

- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true

- name: Build
env:
RUSTFLAGS: -Cinstrument-coverage
run: cargo build

- name: Test
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
LLVM_PROFILE_FILE: grcov-%p-%m.profraw
RUSTFLAGS: -Cinstrument-coverage
run: cargo test

- name: Generate coverage
run: |
cargo install grcov
grcov $(find . -name "grcov-*.profraw" -print) \
--branch \
--ignore-not-existing \
--binary-path ./target/debug/ \
-s . \
-t lcov \
--ignore "/*" \
-o lcov.info
- name: Upload to CodeCov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./lcov.info
fail_ci_if_error: true
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![Crates.io](https://img.shields.io/crates/v/symbiosis-api.svg)](https://crates.io/crates/symbiosis-api)
[![Documentation](https://docs.rs/symbiosis-api/badge.svg)](https://docs.rs/symbiosis-api/)
[![Codecov](https://codecov.io/github/phnaharris/symbiosis-api/coverage.svg?branch=main)](https://codecov.io/gh/phnaharris/symbiosis-api)
[![codecov](https://codecov.io/gh/phnaharris/symbiosis-api-rs/graph/badge.svg?token=AWZJZFZCMH)](https://codecov.io/gh/phnaharris/symbiosis-api-rs)
[![Build Status](https://github.com/phnaharris/symbiosis-api-rs/actions/workflows/main.yml/badge.svg)](https://github.com/phnaharris/symbiosis-api-rs/actions/workflows/main.yml)

A high-level binding for Symbiosis API, written in Rust.
Expand Down
2 changes: 1 addition & 1 deletion README.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![Crates.io](https://img.shields.io/crates/v/symbiosis-api.svg)](https://crates.io/crates/symbiosis-api)
[![Documentation](https://docs.rs/symbiosis-api/badge.svg)](https://docs.rs/symbiosis-api/)
[![Codecov](https://codecov.io/github/phnaharris/symbiosis-api/coverage.svg?branch=main)](https://codecov.io/gh/phnaharris/symbiosis-api)
[![codecov](https://codecov.io/gh/phnaharris/symbiosis-api-rs/graph/badge.svg?token=AWZJZFZCMH)](https://codecov.io/gh/phnaharris/symbiosis-api-rs)
[![Build Status](https://github.com/phnaharris/symbiosis-api-rs/actions/workflows/main.yml/badge.svg)](https://github.com/phnaharris/symbiosis-api-rs/actions/workflows/main.yml)

{{readme}}
3 changes: 3 additions & 0 deletions src/api/bridging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,6 @@ impl BridgeResponse {
self.approve_to
}
}

#[cfg(test)]
mod tests {}
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@

#![deny(missing_docs)]
#![warn(missing_debug_implementations, rust_2018_idioms, rustdoc::all)]
#![allow(rustdoc::missing_doc_code_examples, rustdoc::private_doc_tests)]
#![allow(rustdoc::private_doc_tests)]
#![cfg_attr(docsrs, feature(doc_cfg))]
#![allow(unused)]

Expand Down
20 changes: 20 additions & 0 deletions src/types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,23 @@ pub enum SymbiosisTradeType {
/// Izumi
Izumi,
}

#[cfg(test)]
mod tests {
use super::SymbiosisTradeType;

#[test]
fn token_types_as_str() {
let items = &[
(SymbiosisTradeType::Dex, "\"dex\""),
(SymbiosisTradeType::OneInch, "\"1inch\""),
(SymbiosisTradeType::OpenOcean, "\"open-ocean\""),
(SymbiosisTradeType::Wrap, "\"wrap\""),
(SymbiosisTradeType::Izumi, "\"izumi\""),
];

for (i, s) in items {
assert_eq!(serde_json::to_string(i).unwrap(), *s);
}
}
}
14 changes: 14 additions & 0 deletions src/types/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,17 @@ pub enum TokenTypes {
/// TRC20 token.
Tron,
}

#[cfg(test)]
mod tests {
use super::TokenTypes;

#[test]
fn token_types_as_str() {
let items = &[(TokenTypes::Evm, "\"evm\""), (TokenTypes::Tron, "\"tron\"")];

for (i, s) in items {
assert_eq!(serde_json::to_string(i).unwrap(), *s);
}
}
}

0 comments on commit 542b867

Please sign in to comment.