@@ -26,7 +26,7 @@ func TestDeepcodeLLMBinding_PublishIssues(t *testing.T) {
2626
2727func TestExplainWithOptions (t * testing.T ) {
2828 t .Run ("success" , func (t * testing.T ) {
29- d , mockHTTPClient := getHTTPMockedBinding (t , & url. URL { Scheme : "http" , Host : "test.com" } )
29+ d , mockHTTPClient := getHTTPMockedBinding (t )
3030
3131 explainResponseJSON := explainResponse {
3232 Status : completeStatus ,
@@ -42,7 +42,8 @@ func TestExplainWithOptions(t *testing.T) {
4242 }
4343 mockHTTPClient .EXPECT ().Do (gomock .Any ()).Return (& mockResponse , nil )
4444 testDiff := "test diff"
45- explanation , err := d .ExplainWithOptions (context .Background (), ExplainOptions {Diffs : []string {testDiff }})
45+ endpoint := & url.URL {Scheme : "http" , Host : "test.com" }
46+ explanation , err := d .ExplainWithOptions (context .Background (), ExplainOptions {Diffs : []string {testDiff }, Endpoint : endpoint })
4647 assert .NoError (t , err )
4748 var exptectedExplanationsResponse explainResponse
4849 err = json .Unmarshal (expectedResponseBody , & exptectedExplanationsResponse )
@@ -56,13 +57,12 @@ func TestExplainWithOptions(t *testing.T) {
5657 })
5758}
5859
59- func getHTTPMockedBinding (t * testing.T , endpoint * url. URL ) (* DeepCodeLLMBindingImpl , * mocks.MockHTTPClient ) {
60+ func getHTTPMockedBinding (t * testing.T ) (* DeepCodeLLMBindingImpl , * mocks.MockHTTPClient ) {
6061 t .Helper ()
6162 ctrl := gomock .NewController (t )
6263 mockHTTPClient := mocks .NewMockHTTPClient (ctrl )
6364 d := NewDeepcodeLLMBinding (
6465 WithHTTPClient (func () http.HTTPClient { return mockHTTPClient }),
65- WithEndpoint (endpoint ),
6666 )
6767 return d , mockHTTPClient
6868}
@@ -83,7 +83,6 @@ func TestNewDeepcodeLLMBinding(t *testing.T) {
8383func TestNewDeepcodeLLMBinding_Defaults (t * testing.T ) {
8484 binding := NewDeepcodeLLMBinding ()
8585
86- assert .NotNil (t , binding .endpoint )
8786 assert .NotNil (t , binding .logger )
8887 assert .NotNil (t , binding .httpClientFunc )
8988 assert .NotNil (t , binding .instrumentor )
@@ -128,55 +127,6 @@ func TestWithOutputFormat(t *testing.T) {
128127 assert .Equal (t , MarkDown , binding .outputFormat )
129128}
130129
131- func TestWithEndpoint (t * testing.T ) {
132- testCases := []struct {
133- name string
134- inputURL string
135- expected url.URL
136- }{
137- {
138- name : "Valid URL" ,
139- inputURL : "http://localhost:8080" ,
140- expected : url.URL {Scheme : "http" , Host : "localhost:8080" },
141- },
142- {
143- name : "URL with Path" ,
144- inputURL : "https://example.com/path/to/resource" ,
145- expected : url.URL {Scheme : "https" , Host : "example.com" , Path : "/path/to/resource" },
146- },
147- {
148- name : "URL with Query Params" ,
149- inputURL : "http://api.example.com?param1=value1¶m2=value2" ,
150- expected : url.URL {Scheme : "http" , Host : "api.example.com" , RawQuery : "param1=value1¶m2=value2" },
151- },
152- }
153-
154- for _ , tc := range testCases {
155- t .Run (tc .name , func (t * testing.T ) {
156- parsedURL , err := url .Parse (tc .inputURL )
157- if err != nil {
158- t .Fatalf ("Failed to parse URL: %v" , err )
159- }
160-
161- binding := & DeepCodeLLMBindingImpl {}
162- WithEndpoint (parsedURL )(binding )
163-
164- if binding .endpoint .Scheme != tc .expected .Scheme {
165- t .Errorf ("Expected Scheme: %s, Got: %s" , tc .expected .Scheme , binding .endpoint .Scheme )
166- }
167- if binding .endpoint .Host != tc .expected .Host {
168- t .Errorf ("Expected Host: %s, Got: %s" , tc .expected .Host , binding .endpoint .Host )
169- }
170- if binding .endpoint .Path != tc .expected .Path {
171- t .Errorf ("Expected Path: %s, Got: %s" , tc .expected .Path , binding .endpoint .Path )
172- }
173- if binding .endpoint .RawQuery != tc .expected .RawQuery {
174- t .Errorf ("Expected RawQuery: %s, Got: %s" , tc .expected .RawQuery , binding .endpoint .RawQuery )
175- }
176- })
177- }
178- }
179-
180130func TestWithInstrumentor (t * testing.T ) {
181131 // Test case 1: Provide a mock instrumentor
182132 binding := & DeepCodeLLMBindingImpl {}
0 commit comments