aboutsummaryrefslogtreecommitdiff
path: root/gemini/gemini_test.go
blob: 1d69498d78b62780998003601dd8704a9714a25d (plain)
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
package gemini

import (
	"strconv"
	"testing"
)

func TestParse(t *testing.T) {
	tables := []struct {
		host string
		port int
		url string
	}{
		{"hostname.com", GeminiPort, "hostname.com:" + strconv.Itoa(GeminiPort)},
		{"hostname.com", 1234, "hostname.com:1234"},
	}

	for _, table := range tables {
		conn, err := Parse("", table.host, table.port)
		if err != nil {
			t.Fatalf("NewGeminiConn error: %s", err.Error())
		}
		if conn.host != table.url {
			t.Fatalf("NewGeminiConn error: wrong hostname %s", conn.host)
		}
	}
}