Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds more tests #16

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.")
})
})
})