Added tests

Signed-off-by: Levi Harrison <git@leviharrison.dev>
pull/9125/head
Levi Harrison 2021-07-27 23:33:25 -04:00
parent 41be43647b
commit 89f154d643
3 changed files with 51 additions and 1 deletions

View File

@ -738,6 +738,7 @@ var expectedConf = &Config{
Filters: []moby.Filter{},
Host: "unix:///var/run/docker.sock",
Port: 80,
HostNetworkHost: "localhost",
RefreshInterval: model.Duration(60 * time.Second),
HTTPClientConfig: config.DefaultHTTPClientConfig,
},

View File

@ -49,7 +49,7 @@ host: %s
tg := tgs[0]
require.NotNil(t, tg)
require.NotNil(t, tg.Targets)
require.Equal(t, 2, len(tg.Targets))
require.Equal(t, 3, len(tg.Targets))
for i, lbls := range []model.LabelSet{
{
@ -93,6 +93,16 @@ host: %s
"__meta_docker_network_name": "dockersd_default",
"__meta_docker_network_scope": "local",
},
{
"__address__": "localhost",
"__meta_docker_container_id": "54ed6cc5c0988260436cb0e739b7b6c9cad6c439a93b4c4fdbe9753e1c94b189",
"__meta_docker_container_label_com_docker_compose_project": "dockersd",
"__meta_docker_container_label_com_docker_compose_service": "host_networking",
"__meta_docker_container_label_com_docker_compose_version": "1.25.0",
"__meta_docker_container_name": "/dockersd_host_networking_1",
"__meta_docker_container_network_mode": "host",
"__meta_docker_network_ip": "",
},
} {
t.Run(fmt.Sprintf("item %d", i), func(t *testing.T) {
require.Equal(t, lbls, tg.Targets[i])

View File

@ -89,5 +89,44 @@
}
},
"Mounts": []
},
{
"Id": "54ed6cc5c0988260436cb0e739b7b6c9cad6c439a93b4c4fdbe9753e1c94b189",
"Names": [
"/dockersd_host_networking_1"
],
"Image": "httpd",
"ImageID": "sha256:73b8cfec11558fe86f565b4357f6d6c8560f4c49a5f15ae970a24da86c9adc93",
"Command": "httpd-foreground",
"Created": 1627440494,
"Ports": [],
"Labels": {
"com.docker.compose.project": "dockersd",
"com.docker.compose.service": "host_networking",
"com.docker.compose.version": "1.25.0"
},
"State": "running",
"Status": "Up 3 minutes",
"HostConfig": { "NetworkMode": "host" },
"NetworkSettings": {
"Networks": {
"host": {
"IPAMConfig": null,
"Links": null,
"Aliases": null,
"NetworkID": "80c4459fa193c5c8b57e90e117d2f899d1a86708e548738149d62e03df0ec35c",
"EndpointID": "e9bea4c499c34bd41609b0e1e9b38f9964c69180c1a22130f28b6af802c156d8",
"Gateway": "",
"IPAddress": "",
"IPPrefixLen": 0,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "",
"DriverOpts": null
}
}
},
"Mounts": []
}
]