-
-
Notifications
You must be signed in to change notification settings - Fork 521
[bugfix] Fix writes to global config from tests #2727
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
Conversation
767bce5
to
b5adcab
Compare
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.
Seems there are a few issues on Windows
Nit: maybe the gptest.NewUnitTester(t)
could return a context too to avoid having to add it to all tests always?
And I guess using ReadOnly
configs might bite us when testing the config options, since ReadOnly
doesn't allow to change values even in memory, right?
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.
I think now such tests aren't actually testing what we think they are testing:
https://github.com/gopasspw/gopass/pull/2727/files#diff-2bf3cbedfee37a38c52d5f08662f0b4b441ce2a1d1fa915c18e348d167d106cbL67-R72
And we do set config options in a few tests:
internal/action/generate_test.go
41: require.NoError(t, act.cfg.Set("", "generate.autoclip", "false"))
159: require.NoError(t, act.cfg.Set("", "generate.autoclip", ov))
161: require.NoError(t, act.cfg.Set("", "generate.autoclip", "true"))
172: require.NoError(t, act.cfg.Set("", "generate.autoclip", ov))
174: require.NoError(t, act.cfg.Set("", "generate.autoclip", "true"))
internal/action/copy_test.go
30: require.NoError(t, act.cfg.Set("", "generate.autoclip", "false"))
113: require.NoError(t, act.cfg.Set("", "generate.autoclip", "false"))
internal/action/create_test.go
29: require.NoError(t, act.cfg.Set("", "core.notifications", "false"))
30: require.NoError(t, act.cfg.Set("", "core.cliptimeout", "1"))
internal/action/find_test.go
33: require.NoError(t, act.cfg.Set("", "generate.autoclip", "false"))
68: require.NoError(t, act.cfg.Set("", "show.safecontent", "true"))
88: require.NoError(t, act.cfg.Set("", "show.safecontent", "false"))
internal/action/show_test.go
70: require.NoError(t, act.cfg.Set("", "show.safecontent", "true"))
143: require.NoError(t, act.cfg.Set("", "show.safecontent", "false"))
418: require.NoError(t, act.cfg.Set("", "domain-alias.foo.de.insteadOf", "foo.com"))
internal/action/insert_test.go
29: require.NoError(t, act.cfg.Set("", "generate.autoclip", "true"))
87: require.NoError(t, act.cfg.Set("", "show.safecontent", "true"))
116: require.NoError(t, act.cfg.Set("", "show.safecontent", "false"))
139: require.NoError(t, act.cfg.Set("", "generate.autoclip", "false"))
and the fact that moving to a ReadOnly
config didn't break any of these tests probably mean they aren't testing useful things?
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.
I think the ReadOnly
naming is misleading here since it really is a noWrites
one, given our gitconfig actually does support readonly configs.
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.
a few more comments
Fixes gopasspw#2725 Signed-off-by: Dominik Schulz <dominik.schulz@gauner.org>
Signed-off-by: Dominik Schulz <dominik.schulz@gauner.org>
Signed-off-by: Dominik Schulz <dominik.schulz@gauner.org>
d22c1b6
to
9f402b7
Compare
Fixes #2725