File tree Expand file tree Collapse file tree 2 files changed +100
-2
lines changed
Expand file tree Collapse file tree 2 files changed +100
-2
lines changed Original file line number Diff line number Diff line change 1+ name : Rust
2+
3+ on :
4+ push :
5+ branches :
6+ - main
7+ pull_request :
8+ branches :
9+ - main
10+
11+ jobs :
12+ rustfmt :
13+ name : 🗊 Formatting
14+ runs-on : ubuntu-latest
15+ steps :
16+ - uses : actions/checkout@v3
17+ - name : Install toolchain
18+ uses : actions-rs/toolchain@v1
19+ with :
20+ profile : minimal
21+ toolchain : nightly
22+ override : true
23+ components : rustfmt
24+ - name : Run cargo fmt
25+ uses : actions-rs/cargo@v1
26+ with :
27+ command : fmt
28+ args : --all -- --check
29+
30+ lint :
31+ name : 🚨 Lint
32+ runs-on : ubuntu-latest
33+ steps :
34+ - uses : actions/checkout@v2
35+ - name : Install packages
36+ run : sudo apt-get install xorg-dev libglu1-mesa-dev
37+ - name : Install toolchain
38+ uses : actions-rs/toolchain@v1
39+ with :
40+ toolchain : stable
41+ override : true
42+ components : clippy
43+ - uses : actions-rs/clippy-check@v1
44+ with :
45+ token : ${{ secrets.GITHUB_TOKEN }}
46+ args : --all-features --all-targets -- -D warnings
47+
48+ test :
49+ name : ✅ Test Suite
50+ runs-on : ubuntu-latest
51+ steps :
52+ - uses : actions/checkout@v2
53+ - name : Install packages
54+ run : sudo apt-get install xorg-dev libglu1-mesa-dev
55+ - uses : actions-rs/toolchain@v1
56+ with :
57+ toolchain : stable
58+ override : true
59+ - uses : Swatinem/rust-cache@v1
60+ - name : Install cargo-nextest
61+ uses : baptiste0928/cargo-install@v1
62+ with :
63+ crate : cargo-nextest
64+ locked : true
65+ - uses : actions-rs/cargo@v1
66+ with :
67+ command : nextest
68+ args : run --retries 5 --workspace --failure-output final
69+
70+ security_audit :
71+ name : 👮 Audit
72+ runs-on : ubuntu-latest
73+ steps :
74+ - uses : actions/checkout@v2
75+ - name : Cache cargo bin
76+ uses : actions/cache@v1
77+ with :
78+ path : ~/.cargo/bin
79+ key : ${{ runner.os }}-cargo-audit
80+ - uses : actions-rs/audit-check@v1
81+ with :
82+ token : ${{ secrets.GITHUB_TOKEN }}
Original file line number Diff line number Diff line change 22extern crate rocket;
33
44#[ get( "/" ) ]
5- fn index ( ) -> & ' static str {
5+ fn hello ( ) -> & ' static str {
66 "Hello, world!"
77}
88
99#[ launch]
1010fn rocket ( ) -> _ {
11- rocket:: build ( ) . mount ( "/" , routes ! [ index] )
11+ rocket:: build ( ) . mount ( "/" , routes ! [ hello] )
12+ }
13+
14+ #[ cfg( test) ]
15+ mod test {
16+ use super :: rocket;
17+ use rocket:: http:: Status ;
18+ use rocket:: local:: blocking:: Client ;
19+
20+ #[ test]
21+ fn test_hello ( ) {
22+ let client = Client :: tracked ( rocket ( ) ) . expect ( "valid rocket instance" ) ;
23+ let response = client. get ( uri ! ( super :: hello) ) . dispatch ( ) ;
24+
25+ assert_eq ! ( response. status( ) , Status :: Ok ) ;
26+ assert_eq ! ( response. into_string( ) . unwrap( ) , "Hello, world!" ) ;
27+ }
1228}
You can’t perform that action at this time.
0 commit comments