Fixes some unit tests to be able to run them on windows#906
Fixes some unit tests to be able to run them on windows#906vdemeester wants to merge 1 commit intodocker:masterfrom
Conversation
| ) | ||
|
|
||
| func TestRunBuildResetsUidAndGidInContext(t *testing.T) { | ||
| skip.IfCondition(t, runtime.GOOS == "windows", "uid and gid not relevant on windows") |
There was a problem hiding this comment.
This check is actually not relevant as assert.Equal(t, uint32(0), fileInfo.Sys().(*syscall.Stat_t).Uid) doesn't compile under windows… I should remove that skip completely.
There was a problem hiding this comment.
Isn't this file already skipped on Windows?
cli/command/trust/key_load_test.go
Outdated
| "testing" | ||
|
|
||
| "github.com/gotestyourself/gotestyourself/skip" | ||
|
|
| expectedMsg: "Unexpected", | ||
| }, | ||
| { | ||
| // FIXME(vdemeester) that doesn't work under windows, the check needs to be smarter |
There was a problem hiding this comment.
This tests fails under Windows because of : 7f53c99#r27815425
There was a problem hiding this comment.
I think the info endpoint could be queried instead of making the assumption that daemon os/platform == client os/platform
There was a problem hiding this comment.
definitely, but probably need to be "skipped" for now, and follow-up on a fix PR for that problem only 👼
e39587d to
f7f4172
Compare
Codecov Report
@@ Coverage Diff @@
## master #906 +/- ##
==========================================
+ Coverage 53.26% 53.32% +0.05%
==========================================
Files 259 258 -1
Lines 16432 16374 -58
==========================================
- Hits 8753 8731 -22
+ Misses 7115 7079 -36
Partials 564 564 |
thaJeztah
left a comment
There was a problem hiding this comment.
LGTM, but left some comments 😅
| func TestHistoryContext_CreatedSince(t *testing.T) { | ||
| dateStr := "2009-11-10T23:00:00Z" | ||
| if runtime.GOOS == "windows" { | ||
| dateStr = "2009-11-11T00:00:00+01:00" |
There was a problem hiding this comment.
arf
Is this dependent on system configuration?
There was a problem hiding this comment.
I'm actually not sure 😓 cc @simonferquel @johnstep
There was a problem hiding this comment.
It seems. the good thing is that the timezone is in the string here, and that the format is in a standard parsable from the time package. Comparison should be done after date/time parsing instead that on strings would be better though (and would not require windows specific code).
There was a problem hiding this comment.
Since we're testing a formatter, which is responsible for formatting output that is seen by a user, I think we should be comparing the string, not a time.Time. The format is relevant here.
| { | ||
| args: []string{"plugin-foo", "nonexistent_context_dir"}, | ||
| expectedError: "no such file or directory", | ||
| expectedError: noSuchFile, |
There was a problem hiding this comment.
Ah, I recall some shenanigans like https://github.com/Microsoft/opengcs/blob/8cfbb6d8ae8203a80464ca6e2bd39102d6fd9deb/service/gcsutils/remotefs/utils.go#L93-L107 and https://github.com/Microsoft/opengcs/blob/8cfbb6d8ae8203a80464ca6e2bd39102d6fd9deb/service/gcsutils/remotefs/utils.go#L36-L50
There was a problem hiding this comment.
I think there is an os.IsNotFound() or os.IsFileNotFound function that would be prettier
There was a problem hiding this comment.
Oh! you're right, was thinking about Linux CLI calling a Windows daemon (in which errors don't match), but that's not the case here
| ) | ||
|
|
||
| func TestRunBuildResetsUidAndGidInContext(t *testing.T) { | ||
| skip.IfCondition(t, runtime.GOOS == "windows", "uid and gid not relevant on windows") |
There was a problem hiding this comment.
Isn't this file already skipped on Windows?
Some of them are skipped for now (because the feature is not supported or needs more work), some of them are fixed. Signed-off-by: Vincent Demeester <[email protected]>
f7f4172 to
8da068f
Compare
| @@ -0,0 +1,54 @@ | |||
| //+build linux | |||
There was a problem hiding this comment.
Could we use skip instead of the build directive? Or does this not build at all on windows?
There was a problem hiding this comment.
@dnephin it doesn't build at all on windows — there was a skip before 😓
| } | ||
|
|
||
| func TestLoadKeyFromPath(t *testing.T) { | ||
| skip.If(t, func() bool { return runtime.GOOS == "windows" }) |
There was a problem hiding this comment.
Instead of the func() bool here you can use IfCondition, or update gotestyourself to 1.3.0 so that If accepts the bool.
Maybe add a reason why as well?
| {Source: "/opt/data", Target: "/var/lib/mysql", Type: "bind"}, | ||
| {Source: workingDir, Target: "/code", Type: "bind"}, | ||
| {Source: workingDir + "/static", Target: "/var/www/html", Type: "bind"}, | ||
| {Source: filepath.Join(workingDir, "/static"), Target: "/var/www/html", Type: "bind"}, |
There was a problem hiding this comment.
remove the / from /static ? Also on opt below.
There was a problem hiding this comment.
oups, I forgot to remove that one 🤦♂️
| func TestHistoryContext_CreatedSince(t *testing.T) { | ||
| dateStr := "2009-11-10T23:00:00Z" | ||
| if runtime.GOOS == "windows" { | ||
| dateStr = "2009-11-11T00:00:00+01:00" |
There was a problem hiding this comment.
It seems. the good thing is that the timezone is in the string here, and that the format is in a standard parsable from the time package. Comparison should be done after date/time parsing instead that on strings would be better though (and would not require windows specific code).
| ) | ||
|
|
||
| func TestRunBuildResetsUidAndGidInContext(t *testing.T) { | ||
| dest := fs.NewDir(t, "test-build-context-dest") |
There was a problem hiding this comment.
Should'nt we run this test on Darwin as well ?
There was a problem hiding this comment.
@simonferquel yes, this is also on my TODO (but I should open an issue to track the work on that)
| { | ||
| args: []string{"plugin-foo", "nonexistent_context_dir"}, | ||
| expectedError: "no such file or directory", | ||
| expectedError: noSuchFile, |
There was a problem hiding this comment.
I think there is an os.IsNotFound() or os.IsFileNotFound function that would be prettier
| expectedMsg: "Unexpected", | ||
| }, | ||
| { | ||
| // FIXME(vdemeester) that doesn't work under windows, the check needs to be smarter |
There was a problem hiding this comment.
I think the info endpoint could be queried instead of making the assumption that daemon os/platform == client os/platform
| {Source: "/opt/data", Target: "/var/lib/mysql", Type: "bind"}, | ||
| {Source: workingDir, Target: "/code", Type: "bind"}, | ||
| {Source: workingDir + "/static", Target: "/var/www/html", Type: "bind"}, | ||
| {Source: filepath.Join(workingDir, "/static"), Target: "/var/www/html", Type: "bind"}, |
| {Source: homeDir + "/configs", Target: "/etc/configs/", Type: "bind", ReadOnly: true}, | ||
| {Source: "datavolume", Target: "/var/lib/mysql", Type: "volume"}, | ||
| {Source: workingDir + "/opt", Target: "/opt", Consistency: "cached", Type: "bind"}, | ||
| {Source: filepath.Join(workingDir, "/opt"), Target: "/opt", Consistency: "cached", Type: "bind"}, |
|
Closing this one as I'm putting the commit in #905 (and I'll take comments into account there) |
Some of them are skipped for now (because the feature is not supported
or needs more work), some of them are fixed.
There is still some errors, but it's a start 👼 🙏
Signed-off-by: Vincent Demeester [email protected]