MCPcopy Create free account
hub / github.com/docker/docker-agent / TestSaveWithCustomFilename

Function TestSaveWithCustomFilename

pkg/evaluation/save_test.go:18–52  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

16)
17
18func TestSaveWithCustomFilename(t *testing.T) {
19 // Create a temporary directory and change to it
20 t.Chdir(t.TempDir())
21
22 // Create a test session
23 sess := session.New()
24 sess.ID = "test-session-id"
25
26 // Test 1: Save with custom filename
27 evalFile, err := Save(sess, "my-custom-eval")
28 require.NoError(t, err)
29 require.Equal(t, filepath.Join("evals", "my-custom-eval.json"), evalFile)
30 require.FileExists(t, evalFile)
31
32 // Verify the saved file contains the evals field
33 data, err := os.ReadFile(evalFile)
34 require.NoError(t, err)
35 var savedSession session.Session
36 err = json.Unmarshal(data, &savedSession)
37 require.NoError(t, err)
38 assert.NotNil(t, savedSession.Evals)
39 assert.Empty(t, savedSession.Evals.Relevance)
40
41 // Test 2: Save without filename (should use session ID)
42 evalFile2, err := Save(sess, "")
43 require.NoError(t, err)
44 require.Equal(t, filepath.Join("evals", sess.ID+".json"), evalFile2)
45 require.FileExists(t, evalFile2)
46
47 // Test 3: Save with same filename (should add _1 suffix)
48 evalFile3, err := Save(sess, "my-custom-eval")
49 require.NoError(t, err)
50 require.Equal(t, filepath.Join("evals", "my-custom-eval_1.json"), evalFile3)
51 require.FileExists(t, evalFile3)
52}
53
54func TestSaveRunSessions(t *testing.T) {
55 t.Parallel()

Callers

nothing calls this directly

Calls 3

NewFunction · 0.92
SaveFunction · 0.85
ReadFileMethod · 0.80

Tested by

no test coverage detected