2015-11-01 17:29:24 -05:00
|
|
|
package common
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestHTTPConfigPrepare_Bounds(t *testing.T) {
|
|
|
|
// Test bad
|
|
|
|
h := HTTPConfig{
|
|
|
|
HTTPPortMin: 1000,
|
|
|
|
HTTPPortMax: 500,
|
|
|
|
}
|
|
|
|
err := h.Prepare(nil)
|
|
|
|
if err == nil {
|
|
|
|
t.Fatal("should have error")
|
|
|
|
}
|
|
|
|
|
|
|
|
// Test good
|
|
|
|
h = HTTPConfig{
|
|
|
|
HTTPPortMin: 0,
|
|
|
|
HTTPPortMax: 0,
|
|
|
|
}
|
|
|
|
err = h.Prepare(nil)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("should not have error: %s", err)
|
|
|
|
}
|
2019-03-19 09:47:21 -04:00
|
|
|
portMin := 8000
|
2015-11-01 17:29:24 -05:00
|
|
|
if h.HTTPPortMin != portMin {
|
|
|
|
t.Fatalf("HTTPPortMin: expected %d got %d", portMin, h.HTTPPortMin)
|
|
|
|
}
|
2019-03-19 09:47:21 -04:00
|
|
|
portMax := 9000
|
2015-11-01 17:29:24 -05:00
|
|
|
if h.HTTPPortMax != portMax {
|
|
|
|
t.Fatalf("HTTPPortMax: expected %d got %d", portMax, h.HTTPPortMax)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Test good
|
|
|
|
h = HTTPConfig{
|
|
|
|
HTTPPortMin: 500,
|
|
|
|
HTTPPortMax: 1000,
|
|
|
|
}
|
|
|
|
err = h.Prepare(nil)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("should not have error: %s", err)
|
|
|
|
}
|
|
|
|
}
|