Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use assert in image package unit tests #31531

Merged
merged 3 commits into from
Mar 16, 2017

Conversation

dnephin
Copy link
Member

@dnephin dnephin commented Mar 3, 2017

Some misc cleanup

  • extract a function from a rather large function in the builder
  • remove setup duplication from the tests in image/
  • use assert.* in the tests to make them more readable, and also for better assertions when an error is expected. Now a specific error message is expected.

@dnephin dnephin changed the title Use assert im image package unit tests Use assert in image package unit tests Mar 3, 2017
@AkihiroSuda
Copy link
Member

SGTM but windowsRS1 failing

00:07:21.216 --- FAIL: TestFSInvalidSet (0.00s)
00:07:21.217 	assert.go:107: fs_test.go:53: Expected error to contain 'is a directory', got 'rename C:\Users\ContainerAdministrator\AppData\Local\Temp\images-fs-store489919157\content\sha256\.tmp-c3ab8ff13720e8ad9047dd39466b3c8974e592c2fa383d4a3960714caef0c4f2553185424 C:\Users\ContainerAdministrator\AppData\Local\Temp\images-fs-store489919157\content\sha256\c3ab8ff13720e8ad9047dd39466b3c8974e592c2fa383d4a3960714caef0c4f2: Access is denied.'
00:07:21.217 --- FAIL: TestFSInvalidRoot (0.00s)
00:07:21.217 	assert.go:107: fs_test.go:80: Expected error to contain 'not a directory', got 'mkdir C:\Users\ContainerAdministrator\AppData\Local\Temp\images-fs-store907166895\root: The system cannot find the path specified.'
00:07:21.218 --- FAIL: TestFSMetadataGetSet (0.02s)
00:07:21.218 	assert.go:107: fs_test.go:120: Expected error to contain 'no such file or directory', got 'open C:\Users\ContainerAdministrator\AppData\Local\Temp\images-fs-store697213506\metadata\sha256\fcde2b2edba56bf408601fb721fe9b5c338d10ee429ea04fae5511b68fbf8fb9\tkey2: The system cannot find the file specified.'
00:07:21.218 --- FAIL: TestFSGetUnsetKey (0.00s)
00:07:21.218 	assert.go:107: fs_test.go:197: Expected error to contain 'no such file or directory', got 'open C:\Users\ContainerAdministrator\AppData\Local\Temp\images-fs-store803968859\content\foobar\abc: The system cannot find the path specified.'
00:07:21.219 --- FAIL: TestFSDelete (0.01s)
00:07:21.219 	assert.go:107: fs_test.go:225: Expected error to contain 'no such file or directory', got 'open C:\Users\ContainerAdministrator\AppData\Local\Temp\images-fs-store710109765\content\sha256\2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae: The system cannot find the file specified.'
00:07:21.219 time="2017-03-03T23:54:24Z" level=error msg="invalid image sha256:f1234d75178d892a133a410355a5a990cf75d2f33eba25d575943d4df632f3a4, invalid character 'i' looking for beginning of value" 
00:07:21.220 --- FAIL: TestRestore (0.10s)
00:07:21.220 	assert.go:107: store_test.go:43: Expected error to contain 'no such file', got 'open C:\Users\ContainerAdministrator\AppData\Local\Temp\images-fs-store684222093\metadata\sha256\f40b4ddcd4289be71c5f8f305c5b8babb4266ef2c39bc599ac968dfc6c8b720e\parent: The system cannot find the path specified.'
00:07:21.220 --- FAIL: TestAddDelete (0.02s)
00:07:21.220 	assert.go:107: store_test.go:93: Expected error to contain 'no such file or directory', got 'open C:\Users\ContainerAdministrator\AppData\Local\Temp\images-fs-store104089660\content\sha256\8d25a9c45df515f9d0fe8e4a6b1c64dd3b965a84790ddbcc7954bb9bc89eb993: The system cannot find the file specified.'
00:07:21.221 FAIL
00:07:21.221 coverage: 82.6% of statements
00:07:21.221 FAIL	github.com/docker/docker/image	0.237s

@AkihiroSuda AkihiroSuda added status/2-code-review status/failing-ci Indicates that the PR in its current state fails the test suite and removed status/0-triage labels Mar 5, 2017
@dnephin
Copy link
Member Author

dnephin commented Mar 6, 2017

I wrapped the errors and fixed the assertions, so part of the error should be consistent between platforms now.

Signed-off-by: Daniel Nephin <dnephin@docker.com>
Signed-off-by: Daniel Nephin <dnephin@docker.com>
Signed-off-by: Daniel Nephin <dnephin@docker.com>
@dnephin dnephin removed rebuild/windowsRS1 status/failing-ci Indicates that the PR in its current state fails the test suite labels Mar 8, 2017
Copy link
Member

@AkihiroSuda AkihiroSuda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

cc @vdemeester

Copy link
Member

@vdemeester vdemeester left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🐯

@vdemeester vdemeester merged commit 2631968 into moby:master Mar 16, 2017
@GordonTheTurtle GordonTheTurtle added this to the 17.05.0 milestone Mar 16, 2017
@dnephin dnephin deleted the cleanup-image-tests branch March 16, 2017 13:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants