Fork of daniellemaywood.uk/gleam — Wasm codegen work
2

Configure Feed

Select the types of activity you want to include in your feed.

gleam / compiler-core / src / error / tests.rs
1.6 kB 55 lines
1// SPDX-License-Identifier: Apache-2.0 2// SPDX-FileCopyrightText: 2024 The Gleam contributors 3 4use super::*; 5use insta::assert_debug_snapshot; 6use insta::assert_snapshot; 7 8#[test] 9fn test_shell_program_not_found_error() { 10 let cmds = vec!["erlc", "rebar3", "deno", "elixir", "node", "bun", "git"]; 11 let oses = vec!["macos", "linux"]; 12 let distros = vec!["ubuntu", "other"]; 13 14 for cmd in &cmds { 15 for os in &oses { 16 if os != &"linux" { 17 let err = Error::ShellProgramNotFound { 18 program: cmd.to_string(), 19 os: parse_os(os, "other"), 20 } 21 .to_diagnostics(); 22 assert_snapshot!( 23 format!("shell_program_not_found_{cmd}_{os}_other"), 24 err[0].text 25 ); 26 } else { 27 for distro in &distros { 28 let err = Error::ShellProgramNotFound { 29 program: cmd.to_string(), 30 os: parse_os(os, distro), 31 } 32 .to_diagnostics(); 33 assert_snapshot!( 34 format!("shell_program_not_found_{cmd}_{os}_{distro}"), 35 err[0].text 36 ); 37 } 38 } 39 } 40 } 41} 42 43#[test] 44fn hex_session_revoked() { 45 let err = Error::HexSessionRevoked.to_diagnostics(); 46 assert_debug_snapshot!(err[0]); 47} 48 49#[test] 50fn hex_error_conversion() { 51 assert_eq!( 52 Error::hex(hexpm::ApiError::OAuthRefreshTokenRejected), 53 Error::HexSessionRevoked 54 ); 55}