-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
cli/compose/loader: use gotest.tools/v3/golden #4610
Conversation
d708ecd
to
a18cd16
Compare
Let me double-check if there was a reason we were using a template for this (to substitute paths); was this for Mac/Linux/Windows? diff --git a/cli/compose/loader/testdata/full-example.json.golden b/cli/compose/loader/testdata/full-example.json.golden
index cea8ac5ef..3c61d6458 100644
--- a/cli/compose/loader/testdata/full-example.json.golden
+++ b/cli/compose/loader/testdata/full-example.json.golden
@@ -1,7 +1,7 @@
{
"configs": {
"config1": {
- "file": "/foo/config_data",
+ "file": "%s/config_data",
"external": false,
"labels": {
"foo": "bar"
@@ -17,7 +17,7 @@
},
"config4": {
"name": "foo",
- "file": "/foo",
+ "file": "%s",
"external": false
}
},
@@ -61,7 +61,7 @@
},
"secrets": {
"secret1": {
- "file": "/foo/secret_data",
+ "file": "%s/secret_data",
"external": false,
"labels": {
"foo": "bar"
@@ -77,7 +77,7 @@
},
"secret4": {
"name": "bar",
- "file": "/foo",
+ "file": "%s",
"external": false
}
},
@@ -472,7 +472,7 @@
},
{
"type": "bind",
- "source": "/foo/static",
+ "source": "%s",
"target": "/var/www/html"
},
{
@@ -488,7 +488,7 @@
},
{
"type": "bind",
- "source": "/foo/opt",
+ "source": "%s",
"target": "/opt",
"consistency": "cached"
},
diff --git a/cli/compose/loader/testdata/full-example.yaml.golden b/cli/compose/loader/testdata/full-example.yaml.golden
index d131dd816..aa2470e02 100644
--- a/cli/compose/loader/testdata/full-example.yaml.golden
+++ b/cli/compose/loader/testdata/full-example.yaml.golden
@@ -274,7 +274,7 @@ services:
source: /foo
target: /code
- type: bind
- source: /foo/static
+ source: %s
target: /var/www/html
- type: bind
source: /bar/configs
@@ -284,7 +284,7 @@ services:
source: datavolume
target: /var/lib/mysql
- type: bind
- source: /foo/opt
+ source: %s
target: /opt
consistency: cached
- type: tmpfs
@@ -376,7 +376,7 @@ volumes:
some-volume: {}
secrets:
secret1:
- file: /foo/secret_data
+ file: %s/secret_data
labels:
foo: bar
secret2:
@@ -387,12 +387,12 @@ secrets:
external: true
secret4:
name: bar
- file: /foo
+ file: %s
x-bar: baz
x-foo: bar
configs:
config1:
- file: /foo/config_data
+ file: %s/config_data
labels:
foo: bar
config2:
@@ -403,7 +403,7 @@ configs:
external: true
config4:
name: foo
- file: /foo
+ file: %s
x-bar: baz
x-foo: bar
x-bar: baz |
filepath.Join(workingDir, "static"), | ||
filepath.Join(workingDir, "opt"), | ||
workingDir, | ||
workingDir, | ||
workingDir, | ||
workingDir) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right; perhaps this was for running the tests on Windows? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks to be indeed; 0cf2e63 (#905)
However, I don't think any of the code is converting these paths; these paths are also "daemon-side", so no conversion is done; there's also other paths in the same file that are unix-style (forward slashes), so I think we should be fine here.
Would be good perhaps if someone could double-check the unit-tests in this package on a Windows machine.
a18cd16
to
3dae6b1
Compare
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## master #4610 +/- ##
=======================================
Coverage 59.72% 59.72%
=======================================
Files 288 288
Lines 24846 24846
=======================================
Hits 14839 14839
Misses 9120 9120
Partials 887 887 |
f7f69f5
to
e173181
Compare
{Source: filepath.Join(workingDir, "static"), Target: "/var/www/html", Type: "bind"}, | ||
{Source: workingDir + "/static", Target: "/var/www/html", Type: "bind"}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GitHub is hiding changes in this file 😞
The tests you modified seems to pass on Windows (they fail before this PR): PS C:\Users\Pawel\Desktop\cli\cli\compose\loader> go test -v . -run '(TestJSONMarshallConfig|TestMarshallConfig)'
=== RUN TestMarshallConfig
--- PASS: TestMarshallConfig (0.01s)
=== RUN TestJSONMarshallConfig
--- PASS: TestJSONMarshallConfig (0.01s)
PASS
ok github.com/docker/cli/cli/compose/loader 0.282s Failures before this PR
however,
|
NIce, even better! I'm guessing the original PR either assumed that these paths were converted, or was previously calling code that assumed that "client" and "daemon" always were the same platform (not taking |
I guess I could reverse the order of the commits, and update the test "before moving to use the golden package". Not sure if worth the effort; WDYT? |
I would say it's not worth the effort and it's fine to fix it after the move to the golden package 😉 |
@vvoland is that a "LGTM"? 😅 |
Nevermind; I somehow glanced over that the second test failed after this and thought the comment described the "before this PR";
|
e173181
to
2d09a8b
Compare
use the golden utility instead of self-crafting expected output, this allows automaticaly updating the expected output. This change does break this specific test on Windows due to platform- specific paths. Other tests already have this issue on Windows, so skipping the test for now. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Paths in the advanced / compose-file format are not converted to be platform-specific, so for these tests, it should not be needed to convert the paths to be Windows-paths. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2d09a8b
to
f2fced4
Compare
I updated |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
use the golden utility instead of self-crafting expected output, this allows automaticaly updating the expected output.
- What I did
- How I did it
- How to verify it
- Description for the changelog
- A picture of a cute animal (not mandatory but encouraged)