From bdb2d33a30765a25be3dd8c82b92517efa00dda8 Mon Sep 17 00:00:00 2001 From: Horus3 Date: Sat, 21 Feb 2015 18:37:28 +0100 Subject: Add basic unit tests. --- app/utilities_test.go | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 app/utilities_test.go (limited to 'app/utilities_test.go') diff --git a/app/utilities_test.go b/app/utilities_test.go new file mode 100644 index 0000000..7037b2f --- /dev/null +++ b/app/utilities_test.go @@ -0,0 +1,33 @@ +package main + +import ( + "testing" +) + +func TestMd5Hash(t *testing.T) { + hash := "f9d08276bc85d30d578e8883f3c7e843" + testHash := Md5Hash("md5hash") + + if hash != testHash { + t.Fatal("Expected %s as hash. Got %s.", hash, testHash) + } +} + +func TestRandomKey(t *testing.T) { + key := RandomKey() + if len(key) != 40 { + t.Fatal("Expected a key with length of 40. Got %s.", key) + } +} + +func TestPassword(t *testing.T) { + + testHash, err := HashPassword("password") + if err != nil { + t.Fatal("Hashing password failed.") + } + verify := VerifyPassword("password", testHash) + if !verify { + t.Fatal("Verifying password failed.") + } +} -- cgit v1.2.3