mirror of
https://github.com/F1bonacc1/process-compose.git
synced 2024-09-11 11:35:26 +03:00
Address (some) PR comments
This commit is contained in:
parent
2cdd62208d
commit
dec74e86df
@ -9,6 +9,7 @@ import (
|
||||
|
||||
type Probe struct {
|
||||
Exec *ExecProbe `yaml:"exec,omitempty"`
|
||||
HttpGet *HttpProbe `yaml:"http_get,omitempty"`
|
||||
Http *HttpProbe `yaml:"http,omitempty"`
|
||||
InitialDelay int `yaml:"initial_delay_seconds,omitempty"`
|
||||
PeriodSeconds int `yaml:"period_seconds,omitempty"`
|
||||
|
@ -1,6 +1,7 @@
|
||||
package health
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"net/url"
|
||||
"reflect"
|
||||
"testing"
|
||||
@ -98,6 +99,54 @@ func TestProbe_validateAndSetDefaults(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestHttpProbe_fields(t *testing.T) {
|
||||
type fields struct {
|
||||
Host string
|
||||
Path string
|
||||
Scheme string
|
||||
Port int
|
||||
Method string
|
||||
StatusCode int
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
fields fields
|
||||
want fields
|
||||
}{
|
||||
{
|
||||
name: "Method and expected status code not set",
|
||||
fields: fields{
|
||||
Host: "google.com",
|
||||
Path: "/isAlive",
|
||||
Scheme: "https",
|
||||
Port: 0,
|
||||
},
|
||||
want: fields{
|
||||
Host: "google.com",
|
||||
Path: "/isAlive",
|
||||
Scheme: "https",
|
||||
Port: 0,
|
||||
Method: http.MethodGet,
|
||||
StatusCode: http.StatusOK,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
hp := HttpProbe(tt.fields)
|
||||
p := Probe{Http: &hp}
|
||||
p.validateAndSetHttpDefaults()
|
||||
if p.Http.Method != http.MethodGet {
|
||||
t.Error("HTTP method was not GET when not set in config file")
|
||||
}
|
||||
if p.Http.StatusCode != http.StatusOK {
|
||||
t.Errorf("HTTP expected status code was not OK (200)")
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestHttpProbe_getUrl(t *testing.T) {
|
||||
type fields struct {
|
||||
Host string
|
||||
|
@ -143,5 +143,6 @@ func renderProbe(probe *health.Probe, tpl *templater.Templater, vars types.Vars)
|
||||
probe.Http.Path = tpl.RenderWithExtraVars(probe.Http.Path, vars)
|
||||
probe.Http.Host = tpl.RenderWithExtraVars(probe.Http.Host, vars)
|
||||
probe.Http.Scheme = tpl.RenderWithExtraVars(probe.Http.Scheme, vars)
|
||||
probe.Http.Method = tpl.RenderWithExtraVars(probe.Http.Method, vars)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user