MCPcopy Create free account
hub / github.com/devnullvoid/pvetui / TestOpenBrowserXdgOpenDetection

Function TestOpenBrowserXdgOpenDetection

internal/vnc/service_test.go:10–36  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

8)
9
10func 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
38func TestCreateShortenedVNCURL(t *testing.T) {
39 tests := []struct {

Callers

nothing calls this directly

Calls 2

openBrowserFunction · 0.85
ErrorMethod · 0.65

Tested by

no test coverage detected