@@ -2,23 +2,17 @@ package eval
22
33import (
44 "context"
5- "encoding/json"
65 "errors"
76 "io"
8- "net/http"
9- "net/http/httptest"
107 "testing"
118
129 "github.com/stretchr/testify/assert"
1310 "github.com/stretchr/testify/require"
1411 "go.opentelemetry.io/otel/attribute"
1512 "go.opentelemetry.io/otel/codes"
1613
17- "github.com/braintrustdata/braintrust-sdk-go/api"
18- "github.com/braintrustdata/braintrust-sdk-go/internal/auth"
1914 "github.com/braintrustdata/braintrust-sdk-go/internal/oteltest"
2015 "github.com/braintrustdata/braintrust-sdk-go/internal/tests"
21- "github.com/braintrustdata/braintrust-sdk-go/logger"
2216 "github.com/braintrustdata/braintrust-sdk-go/trace"
2317)
2418
@@ -264,77 +258,6 @@ func TestNewEval_DefaultParallelism(t *testing.T) {
264258 assert .Equal (t , 1 , ute2 .eval .goroutines )
265259}
266260
267- func TestEval_Run_TraceRefUsesRootTraceID (t * testing.T ) {
268- t .Parallel ()
269-
270- var gotRootSpanID string
271- server := httptest .NewServer (http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
272- require .Equal (t , http .MethodPost , r .Method )
273- require .Equal (t , "/function/invoke" , r .URL .Path )
274-
275- var body map [string ]any
276- require .NoError (t , json .NewDecoder (r .Body ).Decode (& body ))
277-
278- input , ok := body ["input" ].(map [string ]any )
279- require .True (t , ok )
280- traceRef , ok := input ["trace_ref" ].(map [string ]any )
281- require .True (t , ok )
282- gotRootSpanID , _ = traceRef ["root_span_id" ].(string )
283-
284- require .NoError (t , json .NewEncoder (w ).Encode ([]map [string ]any {
285- {"role" : "user" , "content" : "hello" },
286- }))
287- }))
288- defer server .Close ()
289-
290- tp , _ := oteltest .Setup (t )
291- tracer := tp .Tracer (t .Name ())
292- session := auth .NewTestSession (
293- "test-key" ,
294- "org-id" ,
295- "org-name" ,
296- server .URL ,
297- server .URL ,
298- server .URL ,
299- logger .Discard (),
300- )
301-
302- cases := NewDataset ([]Case [testInput , testOutput ]{
303- {
304- Input : testInput {Value : "abc" },
305- Expected : testOutput {Result : "output-abc" },
306- },
307- })
308- task := T (func (ctx context.Context , input testInput ) (testOutput , error ) {
309- return testOutput {Result : "output-" + input .Value }, nil
310- })
311- scorer := NewScorer ("thread" , func (ctx context.Context , result TaskResult [testInput , testOutput ]) (Scores , error ) {
312- _ , _ = result .Thread (ctx )
313- return S (1 ), nil
314- })
315-
316- apiClient := api .NewClient ("test-key" , api .WithAPIURL (server .URL ))
317-
318- e := testNewEval (
319- session ,
320- tracer ,
321- apiClient ,
322- "exp-123" ,
323- "test-exp" ,
324- "proj-123" ,
325- "test-proj" ,
326- cases ,
327- task ,
328- []Scorer [testInput , testOutput ]{scorer },
329- 1 ,
330- )
331-
332- _ , err := e .run (context .Background ())
333- require .NoError (t , err )
334- require .NotEmpty (t , gotRootSpanID )
335- assert .Regexp (t , "^[0-9a-f]{32}$" , gotRootSpanID , "root_span_id should use trace/root ID format" )
336- }
337-
338261func TestEval_Run_TaskError (t * testing.T ) {
339262 t .Parallel ()
340263
0 commit comments