Skip to content

Commit af27a59

Browse files
committed
chore: fix e2e tests
1 parent 5502afa commit af27a59

File tree

1 file changed

+14
-21
lines changed

1 file changed

+14
-21
lines changed

e2e/e2e_test.go

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ package e2e_test
44

55
import (
66
"context"
7-
"encoding/base64"
87
"encoding/json"
98
"fmt"
109
"net/http"
@@ -508,17 +507,14 @@ func TestFileDeletion(t *testing.T) {
508507
require.NoError(t, err, "expected to call 'get_file_contents' tool successfully")
509508
require.False(t, resp.IsError, fmt.Sprintf("expected result not to be an error: %+v", resp))
510509

511-
textContent, ok = resp.Content[0].(mcp.TextContent)
512-
require.True(t, ok, "expected content to be of type TextContent")
510+
embeddedResource, ok := resp.Content[1].(mcp.EmbeddedResource)
511+
require.True(t, ok, "expected content to be of type EmbeddedResource")
513512

514-
var trimmedGetFileText struct {
515-
Content string `json:"content"`
516-
}
517-
err = json.Unmarshal([]byte(textContent.Text), &trimmedGetFileText)
518-
require.NoError(t, err, "expected to unmarshal text content successfully")
519-
b, err := base64.StdEncoding.DecodeString(trimmedGetFileText.Content)
520-
require.NoError(t, err, "expected to decode base64 content successfully")
521-
require.Equal(t, fmt.Sprintf("Created by e2e test %s", t.Name()), string(b), "expected file content to match")
513+
// raw api
514+
textResource, ok := embeddedResource.Resource.(mcp.TextResourceContents)
515+
require.True(t, ok, "expected embedded resource to be of type TextResourceContents")
516+
517+
require.Equal(t, fmt.Sprintf("Created by e2e test %s", t.Name()), textResource.Text, "expected file content to match")
522518

523519
// Delete the file
524520
deleteFileRequest := mcp.CallToolRequest{}
@@ -703,17 +699,14 @@ func TestDirectoryDeletion(t *testing.T) {
703699
require.NoError(t, err, "expected to call 'get_file_contents' tool successfully")
704700
require.False(t, resp.IsError, fmt.Sprintf("expected result not to be an error: %+v", resp))
705701

706-
textContent, ok = resp.Content[0].(mcp.TextContent)
707-
require.True(t, ok, "expected content to be of type TextContent")
702+
embeddedResource, ok := resp.Content[1].(mcp.EmbeddedResource)
703+
require.True(t, ok, "expected content to be of type EmbeddedResource")
708704

709-
var trimmedGetFileText struct {
710-
Content string `json:"content"`
711-
}
712-
err = json.Unmarshal([]byte(textContent.Text), &trimmedGetFileText)
713-
require.NoError(t, err, "expected to unmarshal text content successfully")
714-
b, err := base64.StdEncoding.DecodeString(trimmedGetFileText.Content)
715-
require.NoError(t, err, "expected to decode base64 content successfully")
716-
require.Equal(t, fmt.Sprintf("Created by e2e test %s", t.Name()), string(b), "expected file content to match")
705+
// raw api
706+
textResource, ok := embeddedResource.Resource.(mcp.TextResourceContents)
707+
require.True(t, ok, "expected embedded resource to be of type TextResourceContents")
708+
709+
require.Equal(t, fmt.Sprintf("Created by e2e test %s", t.Name()), textResource.Text, "expected file content to match")
717710

718711
// Delete the directory containing the file
719712
deleteFileRequest := mcp.CallToolRequest{}

0 commit comments

Comments
 (0)