()
| 29 | ) |
| 30 | |
| 31 | func 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 | |
| 55 | func makeTestLog(tb testing.TB, dir, fn string, numlines int) string { |
| 56 | tb.Helper() |
no test coverage detected