Update nonce func and test coverage

This commit is contained in:
Adrian Gallagher
2017-10-04 17:22:44 +11:00
parent 8bfc943178
commit 61023f9fed
2 changed files with 19 additions and 4 deletions

View File

@@ -60,11 +60,26 @@ func TestString(t *testing.T) {
func TestGetValue(t *testing.T) {
var nonce Nonce
timeNowNano := strconv.FormatInt(time.Now().UnixNano(), 10)
time.Sleep(time.Millisecond * 100)
nValue := nonce.GetValue("dingdong", true).String()
if timeNowNano == nValue {
t.Error("Test failed - GetValue() error, incorrect values")
}
if len(nValue) != 19 {
t.Error("Test failed - GetValue() error, incorrect values")
}
timeNowUnix := nonce.GetValue("dongding", false)
if len(timeNowUnix.String()) != 10 {
t.Error("Test failed - GetValue() error, incorrect values")
}
n := nonce.GetValue("dongding", false)
if n != timeNowUnix+1 {
t.Error("Test failed - GetValue() error, incorrect values")
}
}
func TestNonceConcurrency(t *testing.T) {

View File

@@ -42,9 +42,9 @@
"Password": "12334",
"Contacts": [
{
"Name": "StyleGherkin",
"Number": "1231424",
"Enabled": true
"name": "StyleGherkin",
"number": "1231424",
"enabled": true
}
]
},
@@ -436,4 +436,4 @@
}
}
]
}
}