MCPcopy Create free account
hub / github.com/AdRoll/baker / randomLogLine

Function randomLogLine

input/list_test.go:31–53  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

29)
30
31func randomLogLine() baker.Record {
32 var ll baker.LogLine
33
34 rand := rand.New(rand.NewSource(0))
35 t0 := time.Date(2015, 8, 1, 15, 0, 0, 0, time.UTC)
36 tlen := 15 * 24 * time.Hour
37 types := []string{"ty1", "ty2", "ty3", "ty4"}
38
39 // Cookie
40 var cookie [16]byte
41 rand.Read(cookie[:])
42 ll.Set(22, []byte(hex.EncodeToString(cookie[:])))
43
44 // Timestamp
45 ts := t0.Add(time.Duration(rand.Int63n(int64(tlen))))
46 ll.Set(19, []byte(strconv.Itoa(int(ts.Unix()))))
47
48 // Type
49 typ := types[rand.Intn(len(types))]
50 ll.Set(0, []byte(typ))
51
52 return &ll
53}
54
55func makeTestLog(tb testing.TB, dir, fn string, numlines int) string {
56 tb.Helper()

Callers 2

writeTestLogFunction · 0.85
mockS3ServiceFunction · 0.85

Calls 3

SetMethod · 0.95
ReadMethod · 0.80
DurationMethod · 0.65

Tested by

no test coverage detected