-
Notifications
You must be signed in to change notification settings - Fork 0
/
readlog_test.go
135 lines (104 loc) · 2.82 KB
/
readlog_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
package ccruncher_test
import (
. "ccruncher"
"os"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("Readlog", func() {
var (
ccLog *CCLog
log *os.File
err error
)
// var logFile *bytes.Reader
const log1 = "fixtures/cclog.1"
const log2 = "fixtures/cclog.2"
const log3 = "fixtures/cclog.3"
const log4 = "fixtures/cclog.4"
BeforeEach(func() {
log, err = os.Open(log2)
Expect(err).NotTo(HaveOccurred())
defer log.Close()
ccLog, err = ParseLog(log)
Expect(err).NotTo(HaveOccurred())
})
Describe("EntriesForRequest", func() {
var requestID string
var entries []LogEntry
BeforeEach(func() {
requestID = "d462237c-c201-4ab2-57c3-e1e79570b0b0::0bfa387c-38df-4053-9dc9-3205d102ddf2"
entries = ccLog.EntriesForRequest(requestID)
})
It("Returns the entries for the specified request", func() {
Expect(entries).To(HaveLen(6))
})
It("Links each entry to the original request", func() {
for _, entry := range entries {
Expect(entry.RequestID()).To(Equal("d462237c-c201-4ab2-57c3-e1e79570b0b0::0bfa387c-38df-4053-9dc9-3205d102ddf2"))
Expect(entry.AppGUID()).To(Equal("3b664a4a-3aba-4a1b-baa7-8ab67b4ade96"))
Expect(entry.HttpMethod()).To(Equal("GET"))
Expect(entry.URIPath()).To(Equal("/v2/apps/3b664a4a-3aba-4a1b-baa7-8ab67b4ade96/stats"))
}
})
It("Does Stuff", func() {
a, _ := entries[0].Render()
Expect(string(a)).To(Equal("a"))
})
})
Describe("RequestsForApp", func() {
var appGUID string
BeforeEach(func() {
appGUID = "1b86d700-1c7f-4479-b232-d677e85131b2"
})
It("Returns the ids of the requests for the specified app", func() {
ids := ccLog.RequestsForApp(appGUID)
Expect(ids).To(HaveLen(2))
})
})
// Describe("LogEntry", func() {
// Describe("String()", func() {
// It("Returns the correct")
// })
// })
Describe("Apps", func() {
BeforeEach(func() {
log, err = os.Open(log4)
Expect(err).NotTo(HaveOccurred())
defer log.Close()
ccLog, err = ParseLog(log)
Expect(err).NotTo(HaveOccurred())
})
It("Returns a list of the app guids in the log", func() {
Expect(ccLog.Apps()).To(HaveLen(6))
})
})
Describe("Entries()", func() {
BeforeEach(func() {
ccLog = &CCLog{}
})
It("Returns all of the log entries", func() {
})
})
Describe("ParseLog", func() {
var ()
It("Parses the log", func() {
log, err = os.Open(log2)
Expect(err).NotTo(HaveOccurred())
defer log.Close()
ccLog, err = ParseLog(log)
Expect(err).NotTo(HaveOccurred())
entries := ccLog.Entries()
Expect(len(entries)).To(Equal(300))
})
Context("When the log is not valid", func() {
It("Returns an error", func() {
log, err = os.Open("fixtures/badlog")
Expect(err).NotTo(HaveOccurred())
defer log.Close()
_, err := ParseLog(log)
Expect(err).To(HaveOccurred())
})
})
})
})