Skip to content

Commit

Permalink
Adds more tests (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
conorgil authored Oct 14, 2021
1 parent 851a75d commit f6dbbcf
Showing 1 changed file with 41 additions and 1 deletion.
42 changes: 41 additions & 1 deletion userlib_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,48 @@ var _ = Describe("Client Tests", func() {
})

Describe("Marshal and Unmarshal", func() {
XIt("should have tests here", func() {
type Something struct {
someString string
}

It("should fail to marshall and unmarshall expected value when casting random bytes to a string", func() {
someBytes := randomBytes(400)
someBytesAsStr := string(someBytes)

original := Something{
someString: someBytesAsStr,
}

marshalled, err := Marshal(original)
Expect(err).To(BeNil(), "Got an error when marhsalling to JSON.")

var unmarshalled Something
err = Unmarshal(marshalled, &unmarshalled)
Expect(err).To(BeNil(), "Got an error when unmarhsalling from JSON.")

Expect(unmarshalled.someString).ToNot(Equal(original.someString),
"The string from random bytes was the expected value after "+
"unmarshalling, when we expected it to be different.")
})

It("should succeed to marshall and unmarshall expected value when sending random bytes into MapKeyFromBytes()", func() {
someBytes := randomBytes(400)
someBytesAsStr := MapKeyFromBytes(someBytes)

original := Something{
someString: someBytesAsStr,
}

marshalled, err := Marshal(original)
Expect(err).To(BeNil(), "Got an error when marhsalling to JSON.")

var unmarshalled Something
err = Unmarshal(marshalled, &unmarshalled)
Expect(err).To(BeNil(), "Got an error when unmarhsalling from JSON.")

Expect(unmarshalled.someString).ToNot(Equal(original.someString),
"The unmarshalled string value did not match the original string "+
"value, but we expected it to.")
})
})
})

0 comments on commit f6dbbcf

Please sign in to comment.