Skip to content

Instantly share code, notes, and snippets.

@YonatanKra
Created August 15, 2023 17:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save YonatanKra/02ba600ed5d5bbdbfd2f2266912d53ec to your computer and use it in GitHub Desktop.
Save YonatanKra/02ba600ed5d5bbdbfd2f2266912d53ec to your computer and use it in GitHub Desktop.
With tests
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
#[tauri::command]
fn greet(name: &str) -> String {
format!("Hello, {}! You've been greeted from Rust!", name)
}
fn main() {
tauri::Builder::default()
.plugin(tauri_plugin_oauth::init())
.invoke_handler(tauri::generate_handler![greet])
.run(tauri::generate_context!())
.expect("error while running tauri application");
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_greet() {
assert_eq!(greet("Johnny"), "Hello, Johnny! You've been greeted from Rust!");
}
#[test]
fn test_greet_badly() {
assert_eq!(greet("Johnny"), "Hello, Bonny! You've been greeted from Rust!");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment