(t *testing.T)
| 159 | } |
| 160 | |
| 161 | func TestWriteJSONPart(t *testing.T) { |
| 162 | // writeJSONPart toggles compression to false if the incoming body is less than 300 bytes, so creating |
| 163 | // a body larger than 300 bytes to test writeJSONPart with compression=true and compression=false |
| 164 | mockFakeBody := func() db.Body { |
| 165 | bytes := base.FastRandBytes(t, 139) |
| 166 | value := fmt.Sprintf("%x", bytes) |
| 167 | return db.Body{"key": "foo", "value": value} |
| 168 | } |
| 169 | |
| 170 | body := mockFakeBody() |
| 171 | log.Printf("body: %v", body) |
| 172 | buffer := &bytes.Buffer{} |
| 173 | writer := multipart.NewWriter(buffer) |
| 174 | bytes, err := base.JSONMarshalCanonical(body) |
| 175 | require.NoError(t, err) |
| 176 | log.Printf("len(bytes): %v", len(bytes)) |
| 177 | assert.NoError(t, writeJSONPart(writer, "application/json", body, true)) |
| 178 | assert.NoError(t, writeJSONPart(writer, "application/json", body, false)) |
| 179 | } |
| 180 | |
| 181 | func TestMd5DigestKey(t *testing.T) { |
| 182 | assert.Equal(t, "md5-rL0Y20zC+Fzt72VPzMSk2A==", md5DigestKey([]byte("foo"))) |
nothing calls this directly
no test coverage detected