/ internal / utilities / fqdn_test.go
fqdn_test.go
 1  package utilities_test
 2  
 3  import (
 4  	"slices"
 5  	"testing"
 6  
 7  	"codeflow.dananglin.me.uk/apollo/enbas/internal/utilities"
 8  )
 9  
10  func TestGetFQDN(t *testing.T) {
11  	testCases := []struct {
12  		instance string
13  		want     string
14  	}{
15  		{
16  			instance: "https://gts.red-crow.private",
17  			want:     "gts.red-crow.private",
18  		},
19  		{
20  			instance: "http://gotosocial.yellow-desert.social",
21  			want:     "gotosocial.yellow-desert.social",
22  		},
23  		{
24  			instance: "fedi.blue-mammoth.party",
25  			want:     "fedi.blue-mammoth.party",
26  		},
27  	}
28  
29  	for _, tc := range slices.All(testCases) {
30  		got := utilities.GetFQDN(tc.instance)
31  		if tc.want != got {
32  			t.Errorf("Unexpected result received: want %q, got %q", tc.want, got)
33  		} else {
34  			t.Logf("Expected result received: got %q", got)
35  		}
36  	}
37  }