Skip to content

Commit

Permalink
use HaveOccured
Browse files Browse the repository at this point in the history
Signed-off-by: Angelo De Caro <[email protected]>
  • Loading branch information
adecaro committed Dec 18, 2024
1 parent 87f26d6 commit a681166
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
20 changes: 10 additions & 10 deletions platform/view/services/metrics/statsd/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ var _ = Describe("Provider", func() {
counter.With("alpha", alpha, "beta", "b").Add(1)
buf := &bytes.Buffer{}
_, err := s.WriteTo(buf)
Expect(err).To(Succeed())
Expect(err).ToNot(HaveOccurred())
Expect(buf.String()).To(Equal(fmt.Sprintf("namespace.subsystem.name.%s.b:%f|c\n", alpha, float64(1))))
}
})
Expand All @@ -70,7 +70,7 @@ var _ = Describe("Provider", func() {

buf := &bytes.Buffer{}
_, err := s.WriteTo(buf)
Expect(err).To(Succeed())
Expect(err).ToNot(HaveOccurred())
Expect(buf.String()).To(Equal("namespace.subsystem.name:1.000000|c\n"))
})
})
Expand All @@ -88,7 +88,7 @@ var _ = Describe("Provider", func() {

buf := &bytes.Buffer{}
_, err := s.WriteTo(buf)
Expect(err).To(Succeed())
Expect(err).ToNot(HaveOccurred())
Expect(buf.String()).To(Equal(fmt.Sprintf("namespace.subsystem.name:%f|c\n", float64(i))))
}
})
Expand Down Expand Up @@ -127,7 +127,7 @@ var _ = Describe("Provider", func() {
gauge.With("alpha", alpha, "beta", "b").Set(float64(i))
buf := &bytes.Buffer{}
_, err := s.WriteTo(buf)
Expect(err).To(Succeed())
Expect(err).ToNot(HaveOccurred())
Expect(buf.String()).To(Equal(fmt.Sprintf("namespace.subsystem.name.%s.b:%f|g\n", alpha, float64(i))))
}
}
Expand All @@ -146,7 +146,7 @@ var _ = Describe("Provider", func() {
}
buf := &bytes.Buffer{}
_, err := s.WriteTo(buf)
Expect(err).To(Succeed())
Expect(err).ToNot(HaveOccurred())
Expect(strings.SplitN(buf.String(), "\n", -1)).To(ConsistOf(
Equal("namespace.subsystem.name.x.b:6.000000|g"),
Equal("namespace.subsystem.name.y.b:6.000000|g"),
Expand All @@ -167,7 +167,7 @@ var _ = Describe("Provider", func() {

buf := &bytes.Buffer{}
_, err := s.WriteTo(buf)
Expect(err).To(Succeed())
Expect(err).ToNot(HaveOccurred())
Expect(buf.String()).To(Equal("namespace.subsystem.name:1.000000|g\n"))
})
})
Expand All @@ -185,7 +185,7 @@ var _ = Describe("Provider", func() {

buf := &bytes.Buffer{}
_, err := s.WriteTo(buf)
Expect(err).To(Succeed())
Expect(err).ToNot(HaveOccurred())
Expect(buf.String()).To(Equal(fmt.Sprintf("namespace.subsystem.name:%f|g\n", float64(i))))
}
})
Expand Down Expand Up @@ -234,7 +234,7 @@ var _ = Describe("Provider", func() {
histogram.With("alpha", alpha, "beta", "b").Observe(float64(i))
buf := &bytes.Buffer{}
_, err := s.WriteTo(buf)
Expect(err).To(Succeed())
Expect(err).ToNot(HaveOccurred())
Expect(buf.String()).To(Equal(fmt.Sprintf("namespace.subsystem.name.%s.b:%f|ms\n", alpha, float64(i))))
}
}
Expand All @@ -252,7 +252,7 @@ var _ = Describe("Provider", func() {

buf := &bytes.Buffer{}
_, err := s.WriteTo(buf)
Expect(err).To(Succeed())
Expect(err).ToNot(HaveOccurred())
Expect(buf.String()).To(Equal("namespace.subsystem.name:1.000000|ms\n"))
})
})
Expand All @@ -270,7 +270,7 @@ var _ = Describe("Provider", func() {

buf := &bytes.Buffer{}
_, err := s.WriteTo(buf)
Expect(err).To(Succeed())
Expect(err).ToNot(HaveOccurred())
Expect(buf.String()).To(Equal(fmt.Sprintf("namespace.subsystem.name:%f|ms\n", float64(i))))
}
})
Expand Down
14 changes: 7 additions & 7 deletions platform/view/services/server/web/middleware/chain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,36 +30,36 @@ var _ = Describe("Chain", func() {
one = func(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
_, err := w.Write([]byte("1:before,"))
Expect(err).To(Succeed())
Expect(err).ToNot(HaveOccurred())
next.ServeHTTP(w, r)
_, err = w.Write([]byte("1:after"))
Expect(err).To(Succeed())
Expect(err).ToNot(HaveOccurred())
})
}
two = func(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
_, err := w.Write([]byte("2:before,"))
Expect(err).To(Succeed())
Expect(err).ToNot(HaveOccurred())
next.ServeHTTP(w, r)
_, err = w.Write([]byte("2:after,"))
Expect(err).To(Succeed())
Expect(err).ToNot(HaveOccurred())
})
}
three = func(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
_, err := w.Write([]byte("3:before,"))
Expect(err).To(Succeed())
Expect(err).ToNot(HaveOccurred())
next.ServeHTTP(w, r)
_, err = w.Write([]byte("3:after,"))
Expect(err).To(Succeed())
Expect(err).ToNot(HaveOccurred())
})
}
chain = middleware.NewChain(one, two, three)

hello = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
_, err := w.Write([]byte("Hello!,"))
Expect(err).To(Succeed())
Expect(err).ToNot(HaveOccurred())
})

req = httptest.NewRequest("GET", "/", nil)
Expand Down

0 comments on commit a681166

Please sign in to comment.