Files

52 lines
1.2 KiB
Go

package labeler
import "testing"
func TestConfig_PublicURL(t *testing.T) {
tests := []struct {
name string
baseURL string
want string
}{
{"standard", "https://atcr.io", "https://labeler.atcr.io"},
{"with port", "https://atcr.io:8080", "https://labeler.atcr.io:8080"},
{"localhost", "http://localhost:5000", "http://labeler.localhost:5000"},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
cfg := &Config{
Server: AppviewServerConfig{BaseURL: tt.baseURL},
}
got := cfg.PublicURL()
if got != tt.want {
t.Errorf("PublicURL() = %q, want %q", got, tt.want)
}
})
}
}
func TestConfig_DID(t *testing.T) {
tests := []struct {
name string
baseURL string
want string
}{
{"standard", "https://atcr.io", "did:web:labeler.atcr.io"},
{"with port", "https://atcr.io:8080", "did:web:labeler.atcr.io%3A8080"},
{"localhost", "http://localhost:5000", "did:web:labeler.localhost%3A5000"},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
cfg := &Config{
Server: AppviewServerConfig{BaseURL: tt.baseURL},
}
got := cfg.DID()
if got != tt.want {
t.Errorf("DID() = %q, want %q", got, tt.want)
}
})
}
}