Skip to content

Commit

Permalink
fix(go): multipart tests
Browse files Browse the repository at this point in the history
  • Loading branch information
loks0n committed Sep 30, 2024
1 parent 0612d4a commit 6b43960
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions tests/languages/go/tests.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,55 @@ func testMultipart(client client.Client){

fmt.Println(data["x"])
fmt.Println(fmt.Sprintf("%x",md5.Sum([]byte(data["responseBody"]))))

stringPayload := payload.NewPayloadFromString("Hello, World!")
mp, er := g.MultipartEcho(stringPayload)

if er != nil { return }

np = *mp
bytesValue, ok = np.([]byte)
if !ok { return }

data, err =parse(bytesValue)
if err != nil { return }

responseBody := data["responseBody"] as payload.Payload
fmt.Println(responseBody.ToString())

jsonPayload := payload.NewPayloadFromJSON(map[string]interface{}{"key": "myStringValue"})
mp, er = g.MultipartEcho(jsonPayload)

if er != nil { return }

np = *mp
bytesValue, ok = np.([]byte)
if !ok { return }

data, err =parse(bytesValue)
if err != nil { return }

responseBody = data["responseBody"] as payload.Payload
fmt.Println(responseBody.ToJson()["key"])

filePayload := payload.NewPayloadFromFile("tests/resources/file.png", "file.png")
mp, er = g.MultipartEcho(filePayload)

if er != nil { return }

np = *mp
bytesValue, ok = np.([]byte)
if !ok { return }

data, err =parse(bytesValue)
if err != nil { return }

responseBody = data["responseBody"] as payload.Payload
responseBody.ToFile("tests/resources/file_copy.png")

file, err := ioutil.ReadFile("tests/resources/file_copy.png")
if err != nil { return }
fmt.Println(fmt.Sprintf("%x",md5.Sum(file)))
}

func testQueries() {
Expand Down

0 comments on commit 6b43960

Please sign in to comment.