@@ -21,38 +21,55 @@ const TEST_MAX_SIZE = 10
21
21
22
22
func Test_GetConfiguration_unknownKey (t * testing.T ) {
23
23
var store = newConfigurationStore (TEST_MAX_SIZE )
24
- store .SetConfigurations (dictionary {"randomization_algo" : testExp })
25
- _ , err := store .GetConfiguration ("unknown_exp" )
24
+ err := store .SetConfigurations (map [string ]experimentConfiguration {
25
+ "randomization_algo" : testExp ,
26
+ })
27
+
28
+ assert .NoError (t , err )
29
+ result , err := store .GetConfiguration ("unknown_exp" )
26
30
27
31
assert .Error (t , err )
32
+ assert .Equal (t , experimentConfiguration {}, result )
28
33
}
29
34
30
35
func Test_GetConfiguration_knownKey (t * testing.T ) {
31
36
var store = newConfigurationStore (TEST_MAX_SIZE )
32
- store .SetConfigurations (dictionary {"randomization_algo" : testExp })
33
- result , _ := store .GetConfiguration ("randomization_algo" )
37
+ err := store .SetConfigurations (map [string ]experimentConfiguration {
38
+ "randomization_algo" : testExp ,
39
+ })
40
+ assert .NoError (t , err )
41
+ result , err := store .GetConfiguration ("randomization_algo" )
34
42
35
43
expected := "randomization_algo"
36
44
45
+ assert .NoError (t , err )
37
46
assert .Equal (t , expected , result .Name )
38
47
}
39
48
40
49
func Test_GetConfiguration_evictsOldEntriesWhenMaxSizeExceeded (t * testing.T ) {
41
50
var store = newConfigurationStore (TEST_MAX_SIZE )
42
- store .SetConfigurations (dictionary {"item_to_be_evicted" : testExp })
43
- result , _ := store .GetConfiguration ("item_to_be_evicted" )
51
+ err := store .SetConfigurations (map [string ]experimentConfiguration {
52
+ "item_to_be_evicted" : testExp ,
53
+ })
54
+ assert .NoError (t , err )
55
+ result , err := store .GetConfiguration ("item_to_be_evicted" )
44
56
45
57
expected := "randomization_algo"
58
+ assert .NoError (t , err )
46
59
assert .Equal (t , expected , result .Name )
47
60
48
61
for i := 0 ; i < TEST_MAX_SIZE ; i ++ {
49
62
dictKey := fmt .Sprintf ("test-entry-%v" , i )
50
- store .SetConfigurations (dictionary {dictKey : testExp })
63
+ err := store .SetConfigurations (map [string ]experimentConfiguration {
64
+ dictKey : testExp ,
65
+ })
66
+ assert .NoError (t , err )
51
67
}
52
68
53
- result , err : = store .GetConfiguration ("item_to_be_evicted" )
69
+ result , err = store .GetConfiguration ("item_to_be_evicted" )
54
70
assert .Error (t , err )
55
71
56
- result , _ = store .GetConfiguration (fmt .Sprintf ("test-entry-%v" , TEST_MAX_SIZE - 1 ))
72
+ result , err = store .GetConfiguration (fmt .Sprintf ("test-entry-%v" , TEST_MAX_SIZE - 1 ))
73
+ assert .NoError (t , err )
57
74
assert .Equal (t , expected , result .Name )
58
75
}
0 commit comments