ooni-probe-cli/internal/engine/tunnel/config_test.go
Simone Basso a9b3a3b3a5
fix(tunnel): pass /absolute/path/to/tor to cretz/bine (#323)
* fix(tunnel): pass /absolute/path/to/tor to cretz/bine

It seems cretz/bine is not aware of https://blog.golang.org/path-security
for now. I am planning to send over a diff for that later today.

In the meanwhile, do the right thing here, and make sure that we obtain
the absolute path to the tor binary before we continue.

This work is part of https://github.com/ooni/probe-engine/issues/283.

* fix tests when tor is not installed
2021-05-04 08:14:25 +02:00

37 lines
697 B
Go

package tunnel
import (
"testing"
"github.com/apex/log"
)
func TestConfigLoggerDefault(t *testing.T) {
config := &Config{}
if config.logger() != defaultLogger {
t.Fatal("not the logger we expected")
}
}
func TestConfigLoggerCustom(t *testing.T) {
config := &Config{Logger: log.Log}
if config.logger() != log.Log {
t.Fatal("not the logger we expected")
}
}
func TestTorBinaryNotSet(t *testing.T) {
config := &Config{}
if config.torBinary() != "tor" {
t.Fatal("not the result we expected")
}
}
func TestTorBinarySet(t *testing.T) {
path := "/usr/local/bin/tor"
config := &Config{TorBinary: path}
if config.torBinary() != path {
t.Fatal("not the result we expected")
}
}