talos/pkg/net/net_test.go
Seán C McCord 5210bf489f fix: enclose address in brackets gRPC client
When talking to an IPv6 address for a gRPC server, enclose the IPv6
address in brackets.

Also fixes backwards implementation of IPv4/IPv6 test.

Fixes #983

Signed-off-by: Seán C McCord <ulexus@gmail.com>
2019-08-10 19:02:39 -07:00

26 lines
730 B
Go

/* 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 http://mozilla.org/MPL/2.0/. */
package net
import (
"testing"
"gotest.tools/assert"
)
func TestEmpty(t *testing.T) {
// added for accurate coverage estimation
//
// please remove it once any unit-test is added
// for this package
}
func TestFormatAddress(t *testing.T) {
assert.Equal(t, FormatAddress("2001:db8::1"), "[2001:db8::1]")
assert.Equal(t, FormatAddress("[2001:db8::1]"), "[2001:db8::1]")
assert.Equal(t, FormatAddress("192.168.1.1"), "192.168.1.1")
assert.Equal(t, FormatAddress("alpha.beta.gamma.com"), "alpha.beta.gamma.com")
}