Lint tests

This commit is contained in:
JY Tan
2025-12-18 17:58:26 -08:00
parent 2abda47b0a
commit 299adcae33
3 changed files with 7 additions and 7 deletions

View File

@@ -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,

View File

@@ -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)

View File

@@ -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)