Im new on golang and Im trying to _test my proxy func, the test passes correctly but when running golangci it gives me the error:
undeclared name: getProxyURL
(typecheck)
if got := getProxyURL(tt.args.campaignCode, urls); got != tt.want {
^
func getProxyURL(campaignCode string, urls map[string]string) string {
if campaignURL, ok := urls[campaignCode]; ok {
return campaignURL
}
return "https://facebook.com"
}
_test
package main
import "testing"
func Test_getProxyURL(t *testing.T) {
type args struct {
campaignCode string
}
urls := make(map[string]string, 0)
urls["82383b80-056b-42e8-b192-9b0f33c4f46e"] = "https://google.com"
urls["negativeTest"] = "https://facebook.com"
tests := []struct {
name string
args args
want string
}{
{
name: "Given an invalid campaign code, we receive facebook url as result",
args: args{campaignCode: "negativeTest"},
want: "https://facebook.com",
}, {
name: "Given an valid campaign code, we receive google url as result",
args: args{campaignCode: "82383b80-056b-42e8-b192-9b0f33c4f46e"},
want: "https://google.com",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := getProxyURL(tt.args.campaignCode, urls); got != tt.want {
t.Errorf("getProxyURL() = %v, want %v", got, tt.want)
}
})
}
}
I cant find the problem