Checkpoint
This commit is contained in:
125 files changed
+59376
No files matched your search
@@ -0,0 +1,34 @@
|
||||
package util_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"git.maze.io/go/harmon/util"
|
||||
)
|
||||
|
||||
func TestMakeAddr(t *testing.T) {
|
||||
var (
|
||||
testDefault = "localhost:80"
|
||||
testCases = []struct {
|
||||
Test string
|
||||
Want string
|
||||
}{
|
||||
{"", testDefault},
|
||||
{"81", "localhost:81"},
|
||||
{"1.1.1.1", "1.1.1.1:80"},
|
||||
{"foo", "foo:80"},
|
||||
{":https", "localhost:https"},
|
||||
{"1.2.3.4:", "1.2.3.4:80"},
|
||||
}
|
||||
)
|
||||
for _, test := range testCases {
|
||||
t.Run(test.Test, func(it *testing.T) {
|
||||
v := util.MakeAddr(test.Test, testDefault)
|
||||
if v != test.Want {
|
||||
it.Fatalf("expected %q to return %q, got %q", test.Test, test.Want, v)
|
||||
} else {
|
||||
it.Logf("%q resolved to %q", test.Test, v)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user