From 299adcae3384e699f05ba6c9e0c3fb97030329de Mon Sep 17 00:00:00 2001 From: JY Tan Date: Thu, 18 Dec 2025 17:58:26 -0800 Subject: [PATCH] Lint tests --- internal/config/config_test.go | 10 +++++----- internal/proxy/http_test.go | 2 +- internal/proxy/socks_test.go | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/internal/config/config_test.go b/internal/config/config_test.go index f56bb5b..cf48692 100644 --- a/internal/config/config_test.go +++ b/internal/config/config_test.go @@ -195,7 +195,7 @@ func TestLoad(t *testing.T) { content: "", setup: func(dir string) string { path := filepath.Join(dir, "empty.json") - _ = os.WriteFile(path, []byte(""), 0o644) + _ = os.WriteFile(path, []byte(""), 0o600) return path }, wantNil: true, @@ -206,7 +206,7 @@ func TestLoad(t *testing.T) { content: " \n\t ", setup: func(dir string) string { path := filepath.Join(dir, "whitespace.json") - _ = os.WriteFile(path, []byte(" \n\t "), 0o644) + _ = os.WriteFile(path, []byte(" \n\t "), 0o600) return path }, wantNil: true, @@ -217,7 +217,7 @@ func TestLoad(t *testing.T) { setup: func(dir string) string { path := filepath.Join(dir, "valid.json") content := `{"network":{"allowedDomains":["example.com"]}}` - _ = os.WriteFile(path, []byte(content), 0o644) + _ = os.WriteFile(path, []byte(content), 0o600) return path }, wantNil: false, @@ -235,7 +235,7 @@ func TestLoad(t *testing.T) { name: "invalid JSON", setup: func(dir string) string { path := filepath.Join(dir, "invalid.json") - _ = os.WriteFile(path, []byte("{invalid json}"), 0o644) + _ = os.WriteFile(path, []byte("{invalid json}"), 0o600) return path }, wantNil: false, @@ -246,7 +246,7 @@ func TestLoad(t *testing.T) { setup: func(dir string) string { path := filepath.Join(dir, "invalid_domain.json") content := `{"network":{"allowedDomains":["*.com"]}}` - _ = os.WriteFile(path, []byte(content), 0o644) + _ = os.WriteFile(path, []byte(content), 0o600) return path }, wantNil: false, diff --git a/internal/proxy/http_test.go b/internal/proxy/http_test.go index 6d80c50..f48b6b9 100644 --- a/internal/proxy/http_test.go +++ b/internal/proxy/http_test.go @@ -229,7 +229,7 @@ func TestNewHTTPProxy(t *testing.T) { t.Run(tt.name, func(t *testing.T) { proxy := NewHTTPProxy(filter, tt.debug, tt.monitor) if proxy == nil { - t.Error("NewHTTPProxy() returned nil") + t.Fatal("NewHTTPProxy() returned nil") } if proxy.debug != tt.debug { t.Errorf("debug = %v, want %v", proxy.debug, tt.debug) diff --git a/internal/proxy/socks_test.go b/internal/proxy/socks_test.go index b123c48..15cf34a 100644 --- a/internal/proxy/socks_test.go +++ b/internal/proxy/socks_test.go @@ -86,7 +86,7 @@ func TestNewSOCKSProxy(t *testing.T) { t.Run(tt.name, func(t *testing.T) { proxy := NewSOCKSProxy(filter, tt.debug, tt.monitor) if proxy == nil { - t.Error("NewSOCKSProxy() returned nil") + t.Fatal("NewSOCKSProxy() returned nil") } if proxy.debug != tt.debug { t.Errorf("debug = %v, want %v", proxy.debug, tt.debug)