Skip to content

[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

Merged
merged 3 commits into from
Dec 1, 2023

Conversation

dominikschulz
Copy link
Member

Fixes #2725

@dominikschulz dominikschulz marked this pull request as ready for review November 26, 2023 10:21
Copy link
Member

@AnomalRoil AnomalRoil left a 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?

Copy link
Member

@AnomalRoil AnomalRoil left a 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?

Copy link
Member

@AnomalRoil AnomalRoil left a 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.

Copy link
Member

@AnomalRoil AnomalRoil left a 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>
@dominikschulz dominikschulz merged commit 263b781 into gopasspw:master Dec 1, 2023
@dominikschulz dominikschulz deleted the fix/issue-2725 branch December 1, 2023 13:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Running go test for gopass modifies global config and also removes mounts
2 participants