Skip to content

Commit

Permalink
genai: add file with 1251 encoding to test error (#228)
Browse files Browse the repository at this point in the history
For #221
  • Loading branch information
eliben authored Nov 25, 2024
1 parent f453d2d commit 0633561
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
15 changes: 14 additions & 1 deletion genai/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ func TestLive(t *testing.T) {
t.Logf("Metadata: %+v\n", file.Metadata)
})

t.Run("txt-encoding-valid", func(t *testing.T) {
t.Run("txt-encoding-valid-utf-8", func(t *testing.T) {
// Upload a file that has valid UTF-8 encoding (ASCII).
poem := uploadFile(t, ctx, client, filepath.Join("testdata", "poem.txt"))
model := client.GenerativeModel("gemini-1.5-flash")
Expand All @@ -522,6 +522,19 @@ func TestLive(t *testing.T) {
}
})

t.Run("txt-encoding-1251", func(t *testing.T) {
// Upload a file that has Windows-1251 encoding. This is not currently
// supported and the API will return an error.
poem := uploadFile(t, ctx, client, filepath.Join("testdata", "1251.txt"))
model := client.GenerativeModel("gemini-1.5-flash")
_, err := model.GenerateContent(ctx,
Text("summarize this"),
FileData{URI: poem.URI})
if err == nil {
t.Error(err)
}
})

t.Run("txt-encoding-invalid", func(t *testing.T) {
// Try uploading a "text" file with garbled encoding (this is just random
// data).
Expand Down
1 change: 1 addition & 0 deletions genai/testdata/1251.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This is a test string with some special characters: ������

0 comments on commit 0633561

Please sign in to comment.