(t *testing.T)
| 7 | ) |
| 8 | |
| 9 | func Test_parsePortForwards(t *testing.T) { |
| 10 | t.Parallel() |
| 11 | |
| 12 | type args struct { |
| 13 | tcpSpecs []string |
| 14 | udpSpecs []string |
| 15 | } |
| 16 | tests := []struct { |
| 17 | name string |
| 18 | args args |
| 19 | want []portForwardSpec |
| 20 | wantErr bool |
| 21 | }{ |
| 22 | { |
| 23 | name: "TCP mixed ports and ranges", |
| 24 | args: args{ |
| 25 | tcpSpecs: []string{ |
| 26 | "8000,8080:8081,9000-9002,9003-9004:9005-9006", |
| 27 | "10000", |
| 28 | "4444-4444", |
| 29 | }, |
| 30 | }, |
| 31 | want: []portForwardSpec{ |
| 32 | {"tcp", noAddr, 8000, 8000}, |
| 33 | {"tcp", noAddr, 8080, 8081}, |
| 34 | {"tcp", noAddr, 9000, 9000}, |
| 35 | {"tcp", noAddr, 9001, 9001}, |
| 36 | {"tcp", noAddr, 9002, 9002}, |
| 37 | {"tcp", noAddr, 9003, 9005}, |
| 38 | {"tcp", noAddr, 9004, 9006}, |
| 39 | {"tcp", noAddr, 10000, 10000}, |
| 40 | {"tcp", noAddr, 4444, 4444}, |
| 41 | }, |
| 42 | }, |
| 43 | { |
| 44 | name: "TCP IPv4 local", |
| 45 | args: args{ |
| 46 | tcpSpecs: []string{"127.0.0.1:8080:8081"}, |
| 47 | }, |
| 48 | want: []portForwardSpec{ |
| 49 | {"tcp", ipv4Loopback, 8080, 8081}, |
| 50 | }, |
| 51 | }, |
| 52 | { |
| 53 | name: "TCP IPv6 local", |
| 54 | args: args{ |
| 55 | tcpSpecs: []string{"[::1]:8080:8081"}, |
| 56 | }, |
| 57 | want: []portForwardSpec{ |
| 58 | {"tcp", ipv6Loopback, 8080, 8081}, |
| 59 | }, |
| 60 | }, |
| 61 | { |
| 62 | name: "UDP with port range", |
| 63 | args: args{ |
| 64 | udpSpecs: []string{"8000,8080-8081"}, |
| 65 | }, |
| 66 | want: []portForwardSpec{ |
nothing calls this directly
no test coverage detected