util_test.go 579 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
package controllers

import (
	"github.com/stretchr/testify/require"
	"testing"
)

func TestHostify(t *testing.T) {
	tests := [][2]string{
		{
			"https://test.infura.io/v1/123456",
			"test.infura.io:443",
		},
		{
			"http://test.infura.io/v1/123456",
			"test.infura.io:80",
		},
		{
			"test.infura.io/v1/123456",
			"test.infura.io:80",
		},
		{
			"test.infura.io",
			"test.infura.io:80",
		},
		{
			"http://sequencer:8545",
			"sequencer:8545",
		},
	}
	for _, tt := range tests {
		t.Run(tt[0], func(t *testing.T) {
			require.Equal(t, tt[1], Hostify(tt[0]))
		})
	}
}