summaryrefslogtreecommitdiff
path: root/app/utilities_test.go
diff options
context:
space:
mode:
authorHorus32015-02-21 18:37:28 +0100
committerHorus32015-02-21 18:37:28 +0100
commitbdb2d33a30765a25be3dd8c82b92517efa00dda8 (patch)
tree7332415c103980a6d4e87ca6b8f563a9f6a87496 /app/utilities_test.go
parentb58e21a525e7e4aeda3ec51bfcb07390af8be465 (diff)
downloadstatuspage-bdb2d33a30765a25be3dd8c82b92517efa00dda8.tar.gz
Add basic unit tests.
Diffstat (limited to 'app/utilities_test.go')
-rw-r--r--app/utilities_test.go33
1 files changed, 33 insertions, 0 deletions
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.")
+ }
+}