func TestMaybeEnableWorksAsIntended(t *testing.T) {
	if selfcensor.Enabled() != false {
		t.Fatal("we need to start with self censorship not enabled")
	}
	err := selfcensor.MaybeEnable("")
	if err != nil {
		t.Fatal(err)
	}
	if selfcensor.Enabled() != false {
		t.Fatal("we expected self censorship to still be not enabled")
	}
}
TestMaybeEnableWorksAsIntended MUST be the second test in this file.
package selfcensor_test
import (
	"context"
	"strings"
	"testing"
	"time"
	"github.com/ooni/probe-engine/netx"
	"github.com/ooni/probe-engine/netx/selfcensor"
)
func TestDisabled(t *testing.T) {
	if selfcensor.Enabled() != false {
		t.Fatal("self censorship should be disabled by default")
	}
	if selfcensor.Attempts() != 0 {
		t.Fatal("we expect no self censorship attempts at the beginning")
	}
	t.Run("the system resolver does not trigger selfcensor events", func(t *testing.T) {
		addrs, err := selfcensor.SystemResolver{}.LookupHost(
			context.Background(), "dns.google",
		)
		if err != nil {
			t.Fatal(err)
		}
		if addrs == nil {
			t.Fatal("expected non-nil addrs here")
		}
		if selfcensor.Attempts() != 0 {
			t.Fatal("we expect no self censorship attempts by default")
		}
	})
	t.Run("the system dialer does not trigger selfcensor events", func(t *testing.T) {
		conn, err := selfcensor.SystemDialer{}.DialContext(
			context.Background(), "tcp", "8.8.8.8:443",
		)
		if err != nil {
			t.Fatal(err)
		}
		if conn == nil {
			t.Fatal("expected non-nil conn here")
		}
		conn.Close()
		if selfcensor.Attempts() != 0 {
			t.Fatal("we expect no self censorship attempts by default")
		}
	})
}
func TestEnableInvalidJSON(t *testing.T) {
	if selfcensor.Enabled() != false {
		t.Fatal("we need to start with self censorship not enabled")
	}
	err := selfcensor.Enable("{")
	if err == nil || !strings.HasSuffix(err.Error(), "unexpected end of JSON input") {
		t.Fatal("not the error we expectd")
	}
	if selfcensor.Enabled() != false {
		t.Fatal("we expected self censorship to still be not enabled")
	}
}