mirror of
https://github.com/psviderski/uncloud.git
synced 2026-08-26 11:03:34 +00:00
* fix: format IPv6 addr correclty for HTTP URL * test: cover changes * test: refactor --------- Co-authored-by: gm0stache <gm0stache@noreply.codeberg.org>
31 lines
572 B
Go
31 lines
572 B
Go
package client
|
|
|
|
import (
|
|
"net/netip"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestGetVerifyURL(t *testing.T) {
|
|
tests := map[string]struct {
|
|
given netip.Addr
|
|
want string
|
|
}{
|
|
"IPv4": {
|
|
given: netip.MustParseAddr("93.184.216.34"),
|
|
want: "http://93.184.216.34:/.uncloud-verify",
|
|
},
|
|
"IPv6": {
|
|
given: netip.MustParseAddr("2001:db8::1"),
|
|
want: "http://[2001:db8::1]:/.uncloud-verify",
|
|
},
|
|
}
|
|
for name, tt := range tests {
|
|
t.Run(name, func(t *testing.T) {
|
|
got := getVerifyURL(tt.given)
|
|
assert.Equal(t, tt.want, got)
|
|
})
|
|
}
|
|
}
|