diff --git a/tests/test_un_cr.cr b/tests/test_un_cr.cr index b74095e..cba0c1c 100755 --- a/tests/test_un_cr.cr +++ b/tests/test_un_cr.cr @@ -107,7 +107,8 @@ else response = HTTP::Client.post(url, headers: headers, body: body) result = JSON.parse(response.body) - api_works = result["stdout"]? && result["stdout"].as_s.includes?("Hello from test") + stdout = result["stdout"]? + api_works = !stdout.nil? && stdout.as_s.includes?("Hello from test") print_test("API endpoint reachable and functional", api_works) rescue ex print_test("API endpoint reachable and functional", false) diff --git a/un.v b/un.v index 337b0fb..2a5ad1b 100644 --- a/un.v +++ b/un.v @@ -179,19 +179,19 @@ fn cmd_key(extend bool, api_key string) { // Try xdg-open (Linux), open (macOS), or start (Windows) mut opened := false - result := os.execute('xdg-open "${url}"') - if result.exit_code == 0 { + xdg_result := os.execute('xdg-open "${url}"') + if xdg_result.exit_code == 0 { opened = true } if !opened { - result2 := os.execute('open "${url}"') - if result2.exit_code == 0 { + mac_result := os.execute('open "${url}"') + if mac_result.exit_code == 0 { opened = true } } if !opened { - result3 := os.execute('cmd /c start "${url}"') - if result3.exit_code != 0 { + win_result := os.execute('cmd /c start "${url}"') + if win_result.exit_code != 0 { eprintln('${red}Error: Could not open browser${reset}') } }