Fix broken api test for service Meta (logical conflict rom OSS). Add test that would make this much easier to catch in future.

This commit is contained in:
Paul Banks 2018-05-12 11:27:44 +01:00 committed by Mitchell Hashimoto
parent f4b8e8c96d
commit c58d47ba59
No known key found for this signature in database
GPG Key ID: 744E147AA52F5B0A
2 changed files with 6 additions and 1 deletions

View File

@ -175,6 +175,7 @@ func (s *HTTPServer) AgentServices(resp http.ResponseWriter, req *http.Request)
ID: s.ID, ID: s.ID,
Service: s.Service, Service: s.Service,
Tags: s.Tags, Tags: s.Tags,
Meta: s.Meta,
Port: s.Port, Port: s.Port,
Address: s.Address, Address: s.Address,
EnableTagOverride: s.EnableTagOverride, EnableTagOverride: s.EnableTagOverride,

View File

@ -56,6 +56,9 @@ func TestAgent_Services(t *testing.T) {
ID: "mysql", ID: "mysql",
Service: "mysql", Service: "mysql",
Tags: []string{"master"}, Tags: []string{"master"},
Meta: map[string]string{
"foo": "bar",
},
Port: 5000, Port: 5000,
} }
require.NoError(t, a.State.AddService(srv1, "")) require.NoError(t, a.State.AddService(srv1, ""))
@ -81,6 +84,7 @@ func TestAgent_Services(t *testing.T) {
val := obj.(map[string]*api.AgentService) val := obj.(map[string]*api.AgentService)
assert.Lenf(t, val, 1, "bad services: %v", obj) assert.Lenf(t, val, 1, "bad services: %v", obj)
assert.Equal(t, 5000, val["mysql"].Port) assert.Equal(t, 5000, val["mysql"].Port)
assert.Equal(t, srv1.Meta, val["mysql"].Meta)
assert.NotNil(t, val["mysql"].Connect) assert.NotNil(t, val["mysql"].Connect)
assert.NotNil(t, val["mysql"].Connect.Proxy) assert.NotNil(t, val["mysql"].Connect.Proxy)
assert.Equal(t, prxy1.ExecMode.String(), string(val["mysql"].Connect.Proxy.ExecMode)) assert.Equal(t, prxy1.ExecMode.String(), string(val["mysql"].Connect.Proxy.ExecMode))