Skip to content

Commit

Permalink
Make assertCleanRegistry consistent with assertCleanFilesystem
Browse files Browse the repository at this point in the history
Behaviour is the same, this simply make the two functions look more
similar.
  • Loading branch information
EduardGomezEscandell committed Nov 27, 2023
1 parent 627ed9e commit 48eec0c
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions end-to-end/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,10 @@ func filesToCleanUp() ([]string, error) {
// assertCleanRegistry returns error if registry key 'UbuntuPro' exists.
// If safety checks are overridden, then the key is removed and no error is returned.
func assertCleanRegistry() error {
if os.Getenv(overrideSafety) != "" {
return cleanupRegistry()
}

k, err := registry.OpenKey(registry.CURRENT_USER, registryPath, registry.READ)
if errors.Is(err, registry.ErrNotExist) {
// Key does not exist, as expected
Expand All @@ -327,11 +331,6 @@ func assertCleanRegistry() error {

k.Close()

// Key exists: this is probably running outside of a clean runner
if os.Getenv(overrideSafety) != "" {
return cleanupRegistry()
}

// Protect unsuspecting users
return fmt.Errorf(`UbuntuPro registry key should not exist. Remove it from your machine `+
`to agree to run this potentially destructive test. It can be located at `+
Expand Down

0 comments on commit 48eec0c

Please sign in to comment.