Skip to content

Commit 381e9f6

Browse files
committed
Add tests for #9
<#9>
1 parent b6302a9 commit 381e9f6

File tree

4 files changed

+42
-1
lines changed

4 files changed

+42
-1
lines changed

.cargo/config.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[target.wasm32-unknown-unknown]
2+
runner = "wasm-bindgen-test-runner"

.github/workflows/ci.yml

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,29 +16,50 @@ jobs:
1616
- beta
1717
- nightly
1818
- '1.46.0'
19+
target:
20+
-
1921
features:
2022
-
2123
- derive
2224
- hmac-sha1
25+
include:
26+
- toolchain: stable
27+
features: ''
28+
target: wasm32-unknown-unknown
2329
steps:
2430
- uses: actions/checkout@v2
2531
- name: Install Rust toolchain
2632
uses: actions-rs/toolchain@v1
2733
with:
2834
toolchain: ${{ matrix.toolchain }}
35+
target: ${{ matrix.target }}
2936
profile: minimal
3037
override: true
3138
id: toolchain
3239
- uses: Swatinem/rust-cache@v1
40+
with:
41+
key: ${{ matrix.target }}
42+
- name: Install `wasm-bindgen-test-runner`
43+
if: matrix.target == 'wasm32-unknown-unknown'
44+
run: |
45+
VER=0.2.78
46+
NAME="wasm-bindgen-$VER-x86_64-unknown-linux-musl"
47+
DIGEST=14f1b0ef9225370f0d270efbdbbfe2cf5eb191d57b8eec14ade69c98c71e226f
48+
curl -fLOsS "https://github.com/rustwasm/wasm-bindgen/releases/download/$VER/$NAME.tar.gz"
49+
sha256sum --check --quiet <<< "$DIGEST $NAME.tar.gz"
50+
tar -xzf "$NAME.tar.gz" "$NAME/wasm-bindgen-test-runner"
51+
mv "$NAME/wasm-bindgen-test-runner" /usr/local/bin/
3352
- run: echo 'RUSTFLAGS=--allow unknown_lints' >> $GITHUB_ENV
3453
if: matrix.toolchain == '1.46.0'
54+
- run: echo 'CARGO_BUILD_TARGET=${{ matrix.target }}' >> $GITHUB_ENV
55+
if: matrix.target != ''
3556
- name: Build `oauth1-request`
3657
uses: actions-rs/cargo@v1
3758
with:
3859
command: build
3960
args: --verbose --tests --manifest-path oauth1-request/Cargo.toml --features=${{ matrix.features }}
4061
- name: Build `examples`
41-
if: ${{ matrix.toolchain != '1.46.0' }}
62+
if: ${{ matrix.target == '' && matrix.toolchain != '1.46.0' }}
4263
uses: actions-rs/cargo@v1
4364
with:
4465
command: build

oauth1-request/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ version-sync = "0.9"
3838
[target.'cfg(all(target_arch = "wasm32", target_os = "unknown"))'.dependencies]
3939
js-sys = "0.3"
4040

41+
[target.'cfg(all(target_arch = "wasm32", target_os = "unknown"))'.dev-dependencies]
42+
getrandom = { version = "0.2", features = ["js"] }
43+
wasm-bindgen-test = "0.3"
44+
4145
[features]
4246
default = ["derive", "hmac-sha1"]
4347
derive = ["oauth1-request-derive"]

oauth1-request/tests/pull_9.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
//! Test for <https://github.com/tesaguri/oauth1-request-rs/pull/9>.
2+
3+
#[cfg(all(target_arch = "wasm32", target_os = "unknown"))]
4+
use wasm_bindgen_test::wasm_bindgen_test as test;
5+
6+
#[test]
7+
fn pull_9() {
8+
let _ = oauth1_request::get(
9+
"",
10+
&(),
11+
&oauth_credentials::Token::from_parts("", "", "", ""),
12+
oauth1_request::HmacSha1,
13+
);
14+
}

0 commit comments

Comments
 (0)