From 88cbb3908d76a1daf6f97c3f0c569f563d1078fc Mon Sep 17 00:00:00 2001
From: Sydney Anne Erickson <sydney@elixxir.io>
Date: Tue, 18 Aug 2020 10:51:25 -0700
Subject: [PATCH] Add params.go and status.go tests for Key

---
 key/params_test.go | 25 +++++++++++++++++++++++++
 key/status_test.go | 21 +++++++++++++++++++++
 2 files changed, 46 insertions(+)
 create mode 100644 key/params_test.go
 create mode 100644 key/status_test.go

diff --git a/key/params_test.go b/key/params_test.go
new file mode 100644
index 000000000..daa2d3040
--- /dev/null
+++ b/key/params_test.go
@@ -0,0 +1,25 @@
+package key
+
+// Testing file for the params.go functions
+
+import "testing"
+
+// Test that the GetDefaultParams function returns the right default data
+func Test_GetDefaultParams(t *testing.T) {
+	p := GetDefaultParams()
+	if p.MinKeys != minKeys {
+		t.Errorf("MinKeys mismatch\r\tGot: %d\r\tExpected: %d", p.MinKeys, minKeys)
+	}
+	if p.MaxKeys != maxKeys {
+		t.Errorf("MinKeys mismatch\r\tGot: %d\r\tExpected: %d", p.MaxKeys, maxKeys)
+	}
+	if p.NumRekeys != numReKeys {
+		t.Errorf("MinKeys mismatch\r\tGot: %d\r\tExpected: %d", p.NumRekeys, numReKeys)
+	}
+	if p.TTLScalar != ttlScalar {
+		t.Errorf("MinKeys mismatch\r\tGot: %d\r\tExpected: %d", p.TTLScalar, ttlScalar)
+	}
+	if p.MinNumKeys != threshold {
+		t.Errorf("MinKeys mismatch\r\tGot: %d\r\tExpected: %d", p.MinNumKeys, threshold)
+	}
+}
diff --git a/key/status_test.go b/key/status_test.go
new file mode 100644
index 000000000..991d76a9d
--- /dev/null
+++ b/key/status_test.go
@@ -0,0 +1,21 @@
+package key
+
+// Testing file for the status.go functions
+
+import "testing"
+
+// Test that Status_String returns the right strings for a status
+func Test_Status_String(t *testing.T) {
+	if Status(Active).String() != "Active" {
+		t.Errorf("Testing Active returned mismatch.\r\tGot: %s\r\tExpected: %s", Status(Active).String(), "Active")
+	}
+	if Status(RekeyNeeded).String() != "Rekey Needed" {
+		t.Errorf("Testing RekeyNeeded returned mismatch.\r\tGot: %s\r\tExpected: %s", Status(RekeyNeeded).String(), "Rekey Needed")
+	}
+	if Status(Empty).String() != "Empty" {
+		t.Errorf("Testing Empty returned mismatch.\r\tGot: %s\r\tExpected: %s", Status(Empty).String(), "Empty")
+	}
+	if Status(RekeyEmpty).String() != "Rekey Empty" {
+		t.Errorf("Testing RekeyEmpty returned mismatch.\r\tGot: %s\r\tExpected: %s", Status(RekeyEmpty).String(), "Rekey Empty")
+	}
+}
-- 
GitLab