mirror of
https://github.com/octoleo/syncthing.git
synced 2024-11-18 11:05:14 +00:00
0da0774ce4
GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/3489
27 lines
696 B
Go
27 lines
696 B
Go
// Copyright (C) 2016 The Syncthing Authors.
|
|
//
|
|
// This Source Code Form is subject to the terms of the Mozilla Public
|
|
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
// You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
|
|
package connections
|
|
|
|
import "testing"
|
|
import "net/url"
|
|
|
|
func TestFixupPort(t *testing.T) {
|
|
cases := [][2]string{
|
|
{"tcp://1.2.3.4:5", "tcp://1.2.3.4:5"},
|
|
{"tcp://1.2.3.4:", "tcp://1.2.3.4:22000"},
|
|
{"tcp://1.2.3.4", "tcp://1.2.3.4:22000"},
|
|
}
|
|
|
|
for _, tc := range cases {
|
|
u0, _ := url.Parse(tc[0])
|
|
u1 := fixupPort(u0, 22000).String()
|
|
if u1 != tc[1] {
|
|
t.Errorf("fixupPort(%q, 22000) => %q, expected %q", tc[0], u1, tc[1])
|
|
}
|
|
}
|
|
}
|