mirror of
https://github.com/kataras/iris.git
synced 2026-01-23 11:56:00 +00:00
a bit linting and some tests are online again
Former-commit-id: bd5463a169a36b078dba1c1b6e7dd3ffbd627617
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
// white-box testing
|
||||
package memstore
|
||||
|
||||
import (
|
||||
@@ -91,3 +92,21 @@ func TestImmutable(t *testing.T) {
|
||||
t.Fatalf("expected objp to be immutable but caller was able to change its value")
|
||||
}
|
||||
}
|
||||
|
||||
func TestImmutableSetOnlyWithSetImmutable(t *testing.T) {
|
||||
var p Store
|
||||
|
||||
p.SetImmutable("objp", &myTestObject{"value"})
|
||||
|
||||
p.Set("objp", &myTestObject{"modified"})
|
||||
vObjP := p.Get("objp").(myTestObject)
|
||||
if vObjP.name == "modified" {
|
||||
t.Fatalf("caller should not be able to change the immutable entry with a simple `Set`")
|
||||
}
|
||||
|
||||
p.SetImmutable("objp", &myTestObject{"value with SetImmutable"})
|
||||
vvObjP := p.Get("objp").(myTestObject)
|
||||
if vvObjP.name != "value with SetImmutable" {
|
||||
t.Fatalf("caller should be able to change the immutable entry with a `SetImmutable`")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user