Lint tests
This commit is contained in:
@@ -195,7 +195,7 @@ func TestLoad(t *testing.T) {
|
|||||||
content: "",
|
content: "",
|
||||||
setup: func(dir string) string {
|
setup: func(dir string) string {
|
||||||
path := filepath.Join(dir, "empty.json")
|
path := filepath.Join(dir, "empty.json")
|
||||||
_ = os.WriteFile(path, []byte(""), 0o644)
|
_ = os.WriteFile(path, []byte(""), 0o600)
|
||||||
return path
|
return path
|
||||||
},
|
},
|
||||||
wantNil: true,
|
wantNil: true,
|
||||||
@@ -206,7 +206,7 @@ func TestLoad(t *testing.T) {
|
|||||||
content: " \n\t ",
|
content: " \n\t ",
|
||||||
setup: func(dir string) string {
|
setup: func(dir string) string {
|
||||||
path := filepath.Join(dir, "whitespace.json")
|
path := filepath.Join(dir, "whitespace.json")
|
||||||
_ = os.WriteFile(path, []byte(" \n\t "), 0o644)
|
_ = os.WriteFile(path, []byte(" \n\t "), 0o600)
|
||||||
return path
|
return path
|
||||||
},
|
},
|
||||||
wantNil: true,
|
wantNil: true,
|
||||||
@@ -217,7 +217,7 @@ func TestLoad(t *testing.T) {
|
|||||||
setup: func(dir string) string {
|
setup: func(dir string) string {
|
||||||
path := filepath.Join(dir, "valid.json")
|
path := filepath.Join(dir, "valid.json")
|
||||||
content := `{"network":{"allowedDomains":["example.com"]}}`
|
content := `{"network":{"allowedDomains":["example.com"]}}`
|
||||||
_ = os.WriteFile(path, []byte(content), 0o644)
|
_ = os.WriteFile(path, []byte(content), 0o600)
|
||||||
return path
|
return path
|
||||||
},
|
},
|
||||||
wantNil: false,
|
wantNil: false,
|
||||||
@@ -235,7 +235,7 @@ func TestLoad(t *testing.T) {
|
|||||||
name: "invalid JSON",
|
name: "invalid JSON",
|
||||||
setup: func(dir string) string {
|
setup: func(dir string) string {
|
||||||
path := filepath.Join(dir, "invalid.json")
|
path := filepath.Join(dir, "invalid.json")
|
||||||
_ = os.WriteFile(path, []byte("{invalid json}"), 0o644)
|
_ = os.WriteFile(path, []byte("{invalid json}"), 0o600)
|
||||||
return path
|
return path
|
||||||
},
|
},
|
||||||
wantNil: false,
|
wantNil: false,
|
||||||
@@ -246,7 +246,7 @@ func TestLoad(t *testing.T) {
|
|||||||
setup: func(dir string) string {
|
setup: func(dir string) string {
|
||||||
path := filepath.Join(dir, "invalid_domain.json")
|
path := filepath.Join(dir, "invalid_domain.json")
|
||||||
content := `{"network":{"allowedDomains":["*.com"]}}`
|
content := `{"network":{"allowedDomains":["*.com"]}}`
|
||||||
_ = os.WriteFile(path, []byte(content), 0o644)
|
_ = os.WriteFile(path, []byte(content), 0o600)
|
||||||
return path
|
return path
|
||||||
},
|
},
|
||||||
wantNil: false,
|
wantNil: false,
|
||||||
|
|||||||
@@ -229,7 +229,7 @@ func TestNewHTTPProxy(t *testing.T) {
|
|||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
proxy := NewHTTPProxy(filter, tt.debug, tt.monitor)
|
proxy := NewHTTPProxy(filter, tt.debug, tt.monitor)
|
||||||
if proxy == nil {
|
if proxy == nil {
|
||||||
t.Error("NewHTTPProxy() returned nil")
|
t.Fatal("NewHTTPProxy() returned nil")
|
||||||
}
|
}
|
||||||
if proxy.debug != tt.debug {
|
if proxy.debug != tt.debug {
|
||||||
t.Errorf("debug = %v, want %v", proxy.debug, tt.debug)
|
t.Errorf("debug = %v, want %v", proxy.debug, tt.debug)
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ func TestNewSOCKSProxy(t *testing.T) {
|
|||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
proxy := NewSOCKSProxy(filter, tt.debug, tt.monitor)
|
proxy := NewSOCKSProxy(filter, tt.debug, tt.monitor)
|
||||||
if proxy == nil {
|
if proxy == nil {
|
||||||
t.Error("NewSOCKSProxy() returned nil")
|
t.Fatal("NewSOCKSProxy() returned nil")
|
||||||
}
|
}
|
||||||
if proxy.debug != tt.debug {
|
if proxy.debug != tt.debug {
|
||||||
t.Errorf("debug = %v, want %v", proxy.debug, tt.debug)
|
t.Errorf("debug = %v, want %v", proxy.debug, tt.debug)
|
||||||
|
|||||||
Reference in New Issue
Block a user