@@ -223,6 +223,29 @@ func TestConfigBindAddrFlag(t *testing.T) {
223223 assert .Equal (t , c .BindAddr , "127.0.0.1:4003" , "" )
224224}
225225
226+ // Ensures that a the Listen Host port overrides the advertised port
227+ func TestConfigBindAddrOverride (t * testing.T ) {
228+ c := NewConfig ()
229+ assert .Nil (t , c .LoadFlags ([]string {"-addr" , "127.0.0.1:4009" , "-bind-addr" , "127.0.0.1:4010" }), "" )
230+ assert .Nil (t , c .Sanitize ())
231+ assert .Equal (t , c .BindAddr , "127.0.0.1:4010" , "" )
232+ }
233+
234+ // Ensures that a the Listen Host inherits its port from the advertised addr
235+ func TestConfigBindAddrInheritPort (t * testing.T ) {
236+ c := NewConfig ()
237+ assert .Nil (t , c .LoadFlags ([]string {"-addr" , "127.0.0.1:4009" , "-bind-addr" , "127.0.0.1" }), "" )
238+ assert .Nil (t , c .Sanitize ())
239+ assert .Equal (t , c .BindAddr , "127.0.0.1:4009" , "" )
240+ }
241+
242+ // Ensures that a port only argument errors out
243+ func TestConfigBindAddrErrorOnNoHost (t * testing.T ) {
244+ c := NewConfig ()
245+ assert .Nil (t , c .LoadFlags ([]string {"-addr" , "127.0.0.1:4009" , "-bind-addr" , ":4010" }), "" )
246+ assert .Error (t , c .Sanitize ())
247+ }
248+
226249// Ensures that the peers can be parsed from the environment.
227250func TestConfigPeersEnv (t * testing.T ) {
228251 withEnv ("ETCD_PEERS" , "coreos.com:4001,coreos.com:4002" , func (c * Config ) {
0 commit comments