mirror of
https://github.com/yusing/godoxy.git
synced 2025-05-20 20:52:33 +02:00
update docker test
This commit is contained in:
parent
c3b779a810
commit
1bac96dc2a
1 changed files with 64 additions and 62 deletions
|
@ -235,73 +235,75 @@ func TestExplicitExclude(t *testing.T) {
|
||||||
ExpectFalse(t, ok)
|
ExpectFalse(t, ok)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestImplicitExclude(t *testing.T) {
|
//! Now nothing will be implicit excluded
|
||||||
var p DockerProvider
|
//
|
||||||
entries, err := p.entriesFromContainerLabels(D.FromDocker(&types.Container{
|
// func TestImplicitExclude(t *testing.T) {
|
||||||
Names: dummyNames,
|
// var p DockerProvider
|
||||||
Labels: map[string]string{
|
// entries, err := p.entriesFromContainerLabels(D.FromDocker(&types.Container{
|
||||||
D.LabelAliases: "a",
|
// Names: dummyNames,
|
||||||
"proxy.a.no_tls_verify": "true",
|
// Labels: map[string]string{
|
||||||
},
|
// D.LabelAliases: "a",
|
||||||
State: "running",
|
// "proxy.a.no_tls_verify": "true",
|
||||||
}, ""))
|
// },
|
||||||
ExpectNoError(t, err.Error())
|
// State: "running",
|
||||||
|
// }, ""))
|
||||||
|
// ExpectNoError(t, err.Error())
|
||||||
|
|
||||||
_, ok := entries.Load("a")
|
// _, ok := entries.Load("a")
|
||||||
ExpectFalse(t, ok)
|
// ExpectFalse(t, ok)
|
||||||
}
|
// }
|
||||||
|
|
||||||
func TestImplicitExcludeNoExposedPort(t *testing.T) {
|
// func TestImplicitExcludeNoExposedPort(t *testing.T) {
|
||||||
var p DockerProvider
|
// var p DockerProvider
|
||||||
entries, err := p.entriesFromContainerLabels(D.FromDocker(&types.Container{
|
// entries, err := p.entriesFromContainerLabels(D.FromDocker(&types.Container{
|
||||||
Image: "redis",
|
// Image: "redis",
|
||||||
Names: []string{"redis"},
|
// Names: []string{"redis"},
|
||||||
Ports: []types.Port{
|
// Ports: []types.Port{
|
||||||
{Type: "tcp", PrivatePort: 6379, PublicPort: 0}, // not exposed
|
// {Type: "tcp", PrivatePort: 6379, PublicPort: 0}, // not exposed
|
||||||
},
|
// },
|
||||||
State: "running",
|
// State: "running",
|
||||||
}, ""))
|
// }, ""))
|
||||||
ExpectNoError(t, err.Error())
|
// ExpectNoError(t, err.Error())
|
||||||
|
|
||||||
_, ok := entries.Load("redis")
|
// _, ok := entries.Load("redis")
|
||||||
ExpectFalse(t, ok)
|
// ExpectFalse(t, ok)
|
||||||
}
|
// }
|
||||||
|
|
||||||
func TestNotExcludeSpecifiedPort(t *testing.T) {
|
// func TestNotExcludeSpecifiedPort(t *testing.T) {
|
||||||
var p DockerProvider
|
// var p DockerProvider
|
||||||
entries, err := p.entriesFromContainerLabels(D.FromDocker(&types.Container{
|
// entries, err := p.entriesFromContainerLabels(D.FromDocker(&types.Container{
|
||||||
Image: "redis",
|
// Image: "redis",
|
||||||
Names: []string{"redis"},
|
// Names: []string{"redis"},
|
||||||
Ports: []types.Port{
|
// Ports: []types.Port{
|
||||||
{Type: "tcp", PrivatePort: 6379, PublicPort: 0}, // not exposed
|
// {Type: "tcp", PrivatePort: 6379, PublicPort: 0}, // not exposed
|
||||||
},
|
// },
|
||||||
Labels: map[string]string{
|
// Labels: map[string]string{
|
||||||
"proxy.redis.port": "6379:6379", // but specified in label
|
// "proxy.redis.port": "6379:6379", // but specified in label
|
||||||
},
|
// },
|
||||||
}, ""))
|
// }, ""))
|
||||||
ExpectNoError(t, err.Error())
|
// ExpectNoError(t, err.Error())
|
||||||
|
|
||||||
_, ok := entries.Load("redis")
|
// _, ok := entries.Load("redis")
|
||||||
ExpectTrue(t, ok)
|
// ExpectTrue(t, ok)
|
||||||
}
|
// }
|
||||||
|
|
||||||
func TestNotExcludeNonExposedPortHostNetwork(t *testing.T) {
|
// func TestNotExcludeNonExposedPortHostNetwork(t *testing.T) {
|
||||||
var p DockerProvider
|
// var p DockerProvider
|
||||||
cont := &types.Container{
|
// cont := &types.Container{
|
||||||
Image: "redis",
|
// Image: "redis",
|
||||||
Names: []string{"redis"},
|
// Names: []string{"redis"},
|
||||||
Ports: []types.Port{
|
// Ports: []types.Port{
|
||||||
{Type: "tcp", PrivatePort: 6379, PublicPort: 0}, // not exposed
|
// {Type: "tcp", PrivatePort: 6379, PublicPort: 0}, // not exposed
|
||||||
},
|
// },
|
||||||
Labels: map[string]string{
|
// Labels: map[string]string{
|
||||||
"proxy.redis.port": "6379:6379",
|
// "proxy.redis.port": "6379:6379",
|
||||||
},
|
// },
|
||||||
}
|
// }
|
||||||
cont.HostConfig.NetworkMode = "host"
|
// cont.HostConfig.NetworkMode = "host"
|
||||||
|
|
||||||
entries, err := p.entriesFromContainerLabels(D.FromDocker(cont, ""))
|
// entries, err := p.entriesFromContainerLabels(D.FromDocker(cont, ""))
|
||||||
ExpectNoError(t, err.Error())
|
// ExpectNoError(t, err.Error())
|
||||||
|
|
||||||
_, ok := entries.Load("redis")
|
// _, ok := entries.Load("redis")
|
||||||
ExpectTrue(t, ok)
|
// ExpectTrue(t, ok)
|
||||||
}
|
// }
|
||||||
|
|
Loading…
Add table
Reference in a new issue