@@ -48,33 +48,29 @@ func TestMain(t *testing.T) {
48
48
main ()
49
49
}
50
50
51
- func TestMainWithTCPEndpoint (t * testing.T ) {
51
+ func TestMainWithUnixSocketError (t * testing.T ) {
52
52
// Skip test on windows
53
53
if runtime .GOOS == "windows" {
54
54
t .Skip ("Skipping test on " , runtime .GOOS )
55
55
}
56
56
57
- // mock the grpcServerRunner
58
- originalGRPCServerRunner := grpcServerRunner
59
- grpcServerRunner = mockRunGRPCServer
60
- defer func () { grpcServerRunner = originalGRPCServerRunner }()
61
-
62
- // Set the blobfuse-proxy-endpoint with TCP
63
- // Use a separate process to avoid flag redefinition issues
64
- os .Args = []string {"cmd" , "-blobfuse-proxy-endpoint=tcp://127.0.0.1:0" }
65
-
66
- // Since we can't call main() directly due to flag conflicts,
67
- // let's test the core functionality instead
68
- proto , addr , err := csicommon .ParseEndpoint ("tcp://127.0.0.1:0" )
57
+ // Test the unix socket path handling logic
58
+ proto , addr , err := csicommon .ParseEndpoint ("unix://tmp/test.sock" )
69
59
if err != nil {
70
60
t .Errorf ("failed to parse endpoint: %v" , err )
71
61
}
72
62
73
- if proto != "tcp " {
74
- t .Errorf ("expected protocol tcp , got %s" , proto )
63
+ if proto != "unix " {
64
+ t .Errorf ("expected protocol unix , got %s" , proto )
75
65
}
76
66
77
- if addr == "" {
78
- t .Errorf ("expected non-empty address" )
67
+ if proto == "unix" {
68
+ addr = "/" + addr
69
+ // Test os.Remove error handling - this tests the error path
70
+ // The function handles the case when file doesn't exist
71
+ err := os .Remove (addr )
72
+ if err != nil && ! os .IsNotExist (err ) {
73
+ t .Logf ("Remove failed as expected: %v" , err )
74
+ }
79
75
}
80
76
}
0 commit comments