mirror of
https://github.com/TwiN/gatus.git
synced 2024-12-22 23:02:22 +01:00
test: Improve coverage for Endpoint.Type()
This commit is contained in:
parent
52d7cb6f04
commit
4857b43771
@ -24,15 +24,16 @@ func TestEndpoint_IsEnabled(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestEndpoint_Type(t *testing.T) {
|
func TestEndpoint_Type(t *testing.T) {
|
||||||
type fields struct {
|
type args struct {
|
||||||
URL string
|
URL string
|
||||||
DNS *DNS
|
DNS *DNS
|
||||||
}
|
}
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
fields fields
|
args args
|
||||||
want EndpointType
|
want EndpointType
|
||||||
}{{
|
}{
|
||||||
fields: fields{
|
{
|
||||||
|
args: args{
|
||||||
URL: "1.1.1.1",
|
URL: "1.1.1.1",
|
||||||
DNS: &DNS{
|
DNS: &DNS{
|
||||||
QueryType: "A",
|
QueryType: "A",
|
||||||
@ -40,37 +41,55 @@ func TestEndpoint_Type(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
want: EndpointTypeDNS,
|
want: EndpointTypeDNS,
|
||||||
}, {
|
},
|
||||||
fields: fields{
|
{
|
||||||
|
args: args{
|
||||||
URL: "tcp://127.0.0.1:6379",
|
URL: "tcp://127.0.0.1:6379",
|
||||||
},
|
},
|
||||||
want: EndpointTypeTCP,
|
want: EndpointTypeTCP,
|
||||||
}, {
|
},
|
||||||
fields: fields{
|
{
|
||||||
|
args: args{
|
||||||
URL: "icmp://example.com",
|
URL: "icmp://example.com",
|
||||||
},
|
},
|
||||||
want: EndpointTypeICMP,
|
want: EndpointTypeICMP,
|
||||||
}, {
|
},
|
||||||
fields: fields{
|
{
|
||||||
|
args: args{
|
||||||
URL: "starttls://smtp.gmail.com:587",
|
URL: "starttls://smtp.gmail.com:587",
|
||||||
},
|
},
|
||||||
want: EndpointTypeSTARTTLS,
|
want: EndpointTypeSTARTTLS,
|
||||||
}, {
|
},
|
||||||
fields: fields{
|
{
|
||||||
|
args: args{
|
||||||
URL: "tls://example.com:443",
|
URL: "tls://example.com:443",
|
||||||
},
|
},
|
||||||
want: EndpointTypeTLS,
|
want: EndpointTypeTLS,
|
||||||
}, {
|
},
|
||||||
fields: fields{
|
{
|
||||||
|
args: args{
|
||||||
URL: "https://twin.sh/health",
|
URL: "https://twin.sh/health",
|
||||||
},
|
},
|
||||||
want: EndpointTypeHTTP,
|
want: EndpointTypeHTTP,
|
||||||
}}
|
},
|
||||||
|
{
|
||||||
|
args: args{
|
||||||
|
URL: "invalid://example.org",
|
||||||
|
},
|
||||||
|
want: EndpointTypeUNKNOWN,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
args: args{
|
||||||
|
URL: "no-scheme",
|
||||||
|
},
|
||||||
|
want: EndpointTypeUNKNOWN,
|
||||||
|
},
|
||||||
|
}
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
t.Run(string(tt.want), func(t *testing.T) {
|
t.Run(string(tt.want), func(t *testing.T) {
|
||||||
endpoint := Endpoint{
|
endpoint := Endpoint{
|
||||||
URL: tt.fields.URL,
|
URL: tt.args.URL,
|
||||||
DNS: tt.fields.DNS,
|
DNS: tt.args.DNS,
|
||||||
}
|
}
|
||||||
if got := endpoint.Type(); got != tt.want {
|
if got := endpoint.Type(); got != tt.want {
|
||||||
t.Errorf("Endpoint.Type() = %v, want %v", got, tt.want)
|
t.Errorf("Endpoint.Type() = %v, want %v", got, tt.want)
|
||||||
|
Loading…
Reference in New Issue
Block a user