Skip to content

Commit 3ea9777

Browse files
committed
fix: writing random log size on test log directory
1 parent d7bf76f commit 3ea9777

File tree

1 file changed

+18
-13
lines changed

1 file changed

+18
-13
lines changed

kindling_test.go

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ package radiance
55

66
import (
77
"context"
8+
"crypto/rand"
9+
"encoding/base64"
810
"log/slog"
911
"os"
1012
"path/filepath"
@@ -45,8 +47,8 @@ func TestKindlingIntegrations(t *testing.T) {
4547
assert func(t *testing.T, err error)
4648
}
4749

48-
email := ""
49-
userID := ""
50+
email := "wendel@getlantern.org"
51+
userID := "aaaaaa"
5052

5153
tests := []testCase{
5254
{
@@ -188,6 +190,19 @@ func TestKindlingIntegrations(t *testing.T) {
188190
dataDir := t.TempDir()
189191
logDir := t.TempDir()
190192
require.NoError(t, common.Init(dataDir, logDir, "TRACE"))
193+
// create a txt file in log dir with random content with 1mb size
194+
// ~1MB payload
195+
const size = 0.007 * 1000000
196+
// Base64 inflates: 3 bytes → 4 chars
197+
raw := make([]byte, size*3/4+3) // +3 to avoid truncation issues
198+
199+
_, err := rand.Read(raw)
200+
require.NoError(t, err)
201+
202+
s := base64.RawURLEncoding.EncodeToString(raw)
203+
s = s[:size] // exact length
204+
require.NoError(t, os.WriteFile(logDir+"/largefile.txt", []byte(s), 0644))
205+
191206
kindlingLogger := &slogWriter{Logger: slog.Default()}
192207

193208
ctx, cancel := context.WithCancel(context.Background())
@@ -205,17 +220,7 @@ func TestKindlingIntegrations(t *testing.T) {
205220
require.NoError(t, err)
206221

207222
t.Run("reporting issue should work", func(t *testing.T) {
208-
// ~15MB payload
209-
// const size = 1 * 1000000
210-
// Base64 inflates: 3 bytes → 4 chars
211-
// raw := make([]byte, size*3/4+3) // +3 to avoid truncation issues
212-
213-
// _, err = rand.Read(raw)
214-
// require.NoError(t, err)
215-
216-
// s := base64.RawURLEncoding.EncodeToString(raw)
217-
// s = s[:size] // exact length
218-
assert.NoError(t, reporter.Report(
223+
tc.assert(t, reporter.Report(
219224
context.Background(),
220225
issue.IssueReport{
221226
Type: "Other",

0 commit comments

Comments
 (0)