Skip to content

Commit

Permalink
refactor: use gomega matchers
Browse files Browse the repository at this point in the history
  • Loading branch information
joaofnds committed Feb 19, 2024
1 parent 1dfc326 commit 82835a0
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 9 deletions.
1 change: 0 additions & 1 deletion adapter/http/fiber_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ var _ = Describe("fiber middlewares", func() {
)

BeforeEach(func() {

fxApp = fxtest.New(
GinkgoT(),
logger.NopLoggerProvider,
Expand Down
4 changes: 2 additions & 2 deletions adapter/metrics/metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ var _ = Describe("/", Ordered, func() {

It("returns how many requests were made", func() {
res := Must2(http.Get(url))
b := Must2(io.ReadAll(res.Body))
Expect(b).To(ContainSubstring(`promhttp_metric_handler_requests_total{code="200"} 1`))
bytes := Must2(io.ReadAll(res.Body))
Expect(bytes).To(ContainSubstring(`promhttp_metric_handler_requests_total{code="200"} 1`))
})
})
8 changes: 4 additions & 4 deletions user/http/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ var _ = Describe("/users", Ordered, func() {
dave := app.User.MustCreateUser("dave")

users := app.User.MustListUsers()
Expect(users).To(Equal([]user.User{bob, dave}))
Expect(users).To(ConsistOf(bob, dave))
})

It("deletes users", func() {
Expand All @@ -91,16 +91,16 @@ var _ = Describe("/users", Ordered, func() {
}))

users := app.User.MustListUsers()
Expect(users).To(Equal([]user.User{bob}))
Expect(users).To(ConsistOf(bob))
})

It("switches feature flag", func() {
bob := app.User.MustCreateUser("bob")
bobFeatures := app.User.MustGetFeature(bob.Name)
Expect(bobFeatures).To(Equal(map[string]any{"cool-feature": "on"}))
Expect(bobFeatures).To(HaveKeyWithValue("cool-feature", "on"))

frank := app.User.MustCreateUser("frank")
frankFeatures := app.User.MustGetFeature(frank.Name)
Expect(frankFeatures).To(Equal(map[string]any{"cool-feature": "off"}))
Expect(frankFeatures).To(HaveKeyWithValue("cool-feature", "off"))
})
})
4 changes: 2 additions & 2 deletions user/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@ var _ = Describe("user service", func() {
Expect(found).To(Equal(user))
})

It("created users appear on users listing", func(ctx SpecContext) {
It("lists created users", func(ctx SpecContext) {
user := Must2(userService.CreateUser(ctx, "joao"))
Expect(userService.List(ctx)).To(ContainElement(user))
})

It("removed users do not appear on users listing", func(ctx SpecContext) {
It("removed users are not listed", func(ctx SpecContext) {
user := Must2(userService.CreateUser(ctx, "joao"))
Must(userService.Remove(ctx, user))

Expand Down

0 comments on commit 82835a0

Please sign in to comment.