mirror of https://github.com/docker/docs.git
Merge pull request #2940 from dgageot/2939-it-ls-headers
FIX #2939 Integration tests for ls headers
This commit is contained in:
commit
8f1877e2be
|
@ -11,11 +11,22 @@ func TestLs(t *testing.T) {
|
|||
defer test.TearDown()
|
||||
|
||||
test.Run("setup", func() {
|
||||
test.Machine("create -d none --url none --engine-label app=1 testmachine5").Should().Succeed()
|
||||
test.Machine("create -d none --url none --engine-label foo=bar --engine-label app=1 testmachine4").Should().Succeed()
|
||||
test.Machine("create -d none --url none testmachine3").Should().Succeed()
|
||||
test.Machine("create -d none --url none testmachine2").Should().Succeed()
|
||||
test.Machine("create -d none --url none testmachine").Should().Succeed()
|
||||
test.Machine("create -d none --url url5 --engine-label app=1 testmachine5").Should().Succeed()
|
||||
test.Machine("create -d none --url url4 --engine-label foo=bar --engine-label app=1 testmachine4").Should().Succeed()
|
||||
test.Machine("create -d none --url url3 testmachine3").Should().Succeed()
|
||||
test.Machine("create -d none --url url2 testmachine2").Should().Succeed()
|
||||
test.Machine("create -d none --url url1 testmachine").Should().Succeed()
|
||||
})
|
||||
|
||||
test.Run("ls: no filter", func() {
|
||||
test.Machine("ls").Should().Succeed().
|
||||
ContainLines(6).
|
||||
MatchLine(0, "NAME[ ]+ACTIVE[ ]+DRIVER[ ]+STATE[ ]+URL[ ]+SWARM[ ]+DOCKER[ ]+ERRORS").
|
||||
MatchLine(1, "testmachine[ ]+-[ ]+none[ ]+Running[ ]+url1[ ]+Unknown[ ]+Unable to query docker version: .*").
|
||||
MatchLine(2, "testmachine2[ ]+-[ ]+none[ ]+Running[ ]+url2[ ]+Unknown[ ]+Unable to query docker version: .*").
|
||||
MatchLine(3, "testmachine3[ ]+-[ ]+none[ ]+Running[ ]+url3[ ]+Unknown[ ]+Unable to query docker version: .*").
|
||||
MatchLine(4, "testmachine4[ ]+-[ ]+none[ ]+Running[ ]+url4[ ]+Unknown[ ]+Unable to query docker version: .*").
|
||||
MatchLine(5, "testmachine5[ ]+-[ ]+none[ ]+Running[ ]+url5[ ]+Unknown[ ]+Unable to query docker version: .*")
|
||||
})
|
||||
|
||||
test.Run("ls: filter on label", func() {
|
||||
|
|
|
@ -51,6 +51,8 @@ type Assertions interface {
|
|||
|
||||
ContainLine(index int, text string) Assertions
|
||||
|
||||
MatchLine(index int, template string) Assertions
|
||||
|
||||
EqualLine(index int, text string) Assertions
|
||||
}
|
||||
|
||||
|
@ -283,6 +285,22 @@ func (dmt *dockerMachineTest) ContainLine(index int, text string) Assertions {
|
|||
return dmt
|
||||
}
|
||||
|
||||
func (dmt *dockerMachineTest) MatchLine(index int, template string) Assertions {
|
||||
if dmt.fatal {
|
||||
return dmt
|
||||
}
|
||||
|
||||
if index >= len(dmt.lines) {
|
||||
return dmt.failExpected("at least %d lines\nGot %d", index+1, len(dmt.lines))
|
||||
}
|
||||
|
||||
if !regexp.MustCompile(template).MatchString(dmt.lines[index]) {
|
||||
return dmt.failExpected("line %d to match '%s'\nGot '%s'", index, template, dmt.lines[index])
|
||||
}
|
||||
|
||||
return dmt
|
||||
}
|
||||
|
||||
func (dmt *dockerMachineTest) EqualLine(index int, text string) Assertions {
|
||||
if dmt.fatal {
|
||||
return dmt
|
||||
|
|
Loading…
Reference in New Issue