diff --git a/end-to-end/main_test.go b/end-to-end/main_test.go index a593ca8e2..2ddc47f38 100644 --- a/end-to-end/main_test.go +++ b/end-to-end/main_test.go @@ -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 @@ -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 `+