feat(oonirun): improve tests (#915)

See https://github.com/ooni/probe/issues/2184

While there, rename `runtimex.PanicIfFalse` to `runtimex.Assert` (it was about time...)
This commit is contained in:
Simone Basso 2022-08-31 18:40:27 +02:00 committed by GitHub
commit d0da224a2a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
32 changed files with 1837 additions and 112 deletions

View file

@ -17,7 +17,7 @@ func acquireUserConsent(miniooniDir string, currentOptions *Options) {
consentFile := path.Join(miniooniDir, "informed")
err := maybeWriteConsentFile(currentOptions.Yes, consentFile)
runtimex.PanicOnError(err, "cannot write informed consent file")
runtimex.PanicIfFalse(
runtimex.Assert(
regularFileExists(consentFile),
riskOfRunningOONI,
)

View file

@ -308,7 +308,7 @@ func mainSingleIteration(logger model.Logger, experimentName string, currentOpti
log.Infof("Current time: %s", time.Now().Format("2006-01-02 15:04:05 MST"))
homeDir := gethomedir(currentOptions.HomeDir)
runtimex.PanicIfFalse(homeDir != "", "home directory is empty")
runtimex.Assert(homeDir != "", "home directory is empty")
miniooniDir := path.Join(homeDir, ".miniooni")
err := os.MkdirAll(miniooniDir, 0700)
runtimex.PanicOnError(err, "cannot create $HOME/.miniooni directory")