Table-driven test for formatRemotePath
(t *testing.T)
| 195 | |
| 196 | // Table-driven test for formatRemotePath |
| 197 | func TestFormatRemotePath_Table(t *testing.T) { |
| 198 | tests := []struct { |
| 199 | name string |
| 200 | host string |
| 201 | path string |
| 202 | expected string |
| 203 | }{ |
| 204 | {"plain IPv4", "10.0.0.1", "/tmp", "10.0.0.1:/tmp"}, |
| 205 | {"IPv6 loopback", "::1", "/tmp", "[::1]:/tmp"}, |
| 206 | {"IPv6 full", "2001:db8::1", "/data", "[2001:db8::1]:/data"}, |
| 207 | {"domain", "example.com", "/file", "example.com:/file"}, |
| 208 | {"empty host", "", "/path", ":/path"}, |
| 209 | {"empty path", "host", "", "host:"}, |
| 210 | {"host with zone", "fe80::1%en0", "/home", "[fe80::1%en0]:/home"}, |
| 211 | } |
| 212 | |
| 213 | for _, tt := range tests { |
| 214 | t.Run(tt.name, func(t *testing.T) { |
| 215 | result := formatRemotePath(tt.host, tt.path) |
| 216 | assert.Equal(t, tt.expected, result) |
| 217 | }) |
| 218 | } |
| 219 | } |
nothing calls this directly
no test coverage detected