Skip to content

Commit

Permalink
Add test for Type.Kind().
Browse files Browse the repository at this point in the history
  • Loading branch information
jmalloc committed Sep 26, 2024
1 parent 3e04a2b commit cc69289
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
11 changes: 1 addition & 10 deletions message/kind.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,7 @@ func (k Kind) Symbol() string {
}

func (k Kind) String() string {
switch k {
case CommandKind:
return "command"
case EventKind:
return "event"
case TimeoutKind:
return "timeout"
default:
panic("invalid kind")
}
return MapKind(k, "command", "event", "timeout")
}

// KindFor returns the [Kind] of the message with type T.
Expand Down
13 changes: 13 additions & 0 deletions message/type_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,19 @@ var _ = Describe("type Type", func() {
})
})

Describe("func Kind()", func() {
It("returns the kind of the message", func() {
mt := TypeOf(CommandA1)
Expect(mt.Kind()).To(Equal(CommandKind))
})

It("panics if the type is the zero-value", func() {
Expect(func() {
Type{}.Kind()
}).To(Panic())
})
})

Describe("func ReflectType()", func() {
It("returns the reflect.Type for the message", func() {
mt := TypeOf(CommandA1)
Expand Down

0 comments on commit cc69289

Please sign in to comment.