(t *testing.T)
| 8 | ) |
| 9 | |
| 10 | func TestOpenBrowserXdgOpenDetection(t *testing.T) { |
| 11 | // Only run this test on Linux |
| 12 | if runtime.GOOS != "linux" { |
| 13 | t.Skip("This test is only relevant on Linux") |
| 14 | } |
| 15 | |
| 16 | // Test that openBrowser returns an error when xdg-open is not found |
| 17 | // We can simulate this by temporarily renaming xdg-open if it exists |
| 18 | _, err := exec.LookPath("xdg-open") |
| 19 | if err != nil { |
| 20 | // xdg-open doesn't exist, so our function should return an error |
| 21 | err := openBrowser("http://example.com") |
| 22 | if err == nil { |
| 23 | t.Error("Expected error when xdg-open is not found, but got nil") |
| 24 | } |
| 25 | if !strings.Contains(err.Error(), "xdg-open not found") { |
| 26 | t.Errorf("Expected error to contain 'xdg-open not found', but got: %v", err) |
| 27 | } |
| 28 | return |
| 29 | } |
| 30 | |
| 31 | // xdg-open exists, so our function should work (or at least not return the specific error) |
| 32 | err = openBrowser("http://example.com") |
| 33 | if err != nil && strings.Contains(err.Error(), "xdg-open not found") { |
| 34 | t.Errorf("Unexpected 'xdg-open not found' error when xdg-open exists: %v", err) |
| 35 | } |
| 36 | } |
| 37 | |
| 38 | func TestCreateShortenedVNCURL(t *testing.T) { |
| 39 | tests := []struct { |
nothing calls this directly
no test coverage detected