From ef53e8b5996855a2db3daefa5efce7f2f6658e79 Mon Sep 17 00:00:00 2001 From: eyedeekay Date: Tue, 20 Aug 2024 19:44:31 -0400 Subject: [PATCH] Look up environment variables and determine if they are set or not instead of checking the value --- contrib/dendrite-demo-i2p/main_i2p.go | 1 + contrib/dendrite-demo-i2p/main_test.go | 3 ++- contrib/dendrite-demo-tor/main_test.go | 3 ++- contrib/dendrite-demo-tor/main_tor.go | 1 + 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/contrib/dendrite-demo-i2p/main_i2p.go b/contrib/dendrite-demo-i2p/main_i2p.go index 202792af4..bfe5730b4 100644 --- a/contrib/dendrite-demo-i2p/main_i2p.go +++ b/contrib/dendrite-demo-i2p/main_i2p.go @@ -44,6 +44,7 @@ import ( var sam, err = goSam.NewClient(*samAddr) +// Dial a network connection to an I2P server or a unix socket. Fail for clearnet addresses. func Dial(network, addr string) (net.Conn, error) { if err != nil { return nil, err diff --git a/contrib/dendrite-demo-i2p/main_test.go b/contrib/dendrite-demo-i2p/main_test.go index d3c5490e4..c90c02908 100644 --- a/contrib/dendrite-demo-i2p/main_test.go +++ b/contrib/dendrite-demo-i2p/main_test.go @@ -14,9 +14,10 @@ import ( // Generate HTML with coverage: go tool cover -html=/somewhere/where/there/is/integrationcover.out -o cover.html // Source: https://dzone.com/articles/measuring-integration-test-coverage-rate-in-pouchc func TestMain(t *testing.T) { - if os.Getenv("CI") != "" { + if _, ex := os.LookupEnv("CI"); ex { t.Skip("skipping test, as no TOR/I2P client is available") } else { + t.Log("running locally, continuing with tests") var ( args []string ) diff --git a/contrib/dendrite-demo-tor/main_test.go b/contrib/dendrite-demo-tor/main_test.go index d3c5490e4..c90c02908 100644 --- a/contrib/dendrite-demo-tor/main_test.go +++ b/contrib/dendrite-demo-tor/main_test.go @@ -14,9 +14,10 @@ import ( // Generate HTML with coverage: go tool cover -html=/somewhere/where/there/is/integrationcover.out -o cover.html // Source: https://dzone.com/articles/measuring-integration-test-coverage-rate-in-pouchc func TestMain(t *testing.T) { - if os.Getenv("CI") != "" { + if _, ex := os.LookupEnv("CI"); ex { t.Skip("skipping test, as no TOR/I2P client is available") } else { + t.Log("running locally, continuing with tests") var ( args []string ) diff --git a/contrib/dendrite-demo-tor/main_tor.go b/contrib/dendrite-demo-tor/main_tor.go index f0249c044..ba240961f 100644 --- a/contrib/dendrite-demo-tor/main_tor.go +++ b/contrib/dendrite-demo-tor/main_tor.go @@ -43,6 +43,7 @@ import ( var t, terr = tor.Start(context.Background(), nil) var tdialer, tderr = t.Dialer(context.TODO(), nil) +// Dial either a unix socket address, or connect to a remote address over Tor. Always uses Tor. func Dial(network, addr string) (net.Conn, error) { if terr != nil { return nil, terr