1
1
/*
2
- * Copyright (c) 2008-2021 , Hazelcast, Inc. All Rights Reserved.
2
+ * Copyright (c) 2008-2022 , Hazelcast, Inc. All Rights Reserved.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License")
5
5
* you may not use this file except in compliance with the License.
@@ -93,23 +93,29 @@ func TestMap_PutWithTTLAndMaxIdle(t *testing.T) {
93
93
func TestMap_PutIfAbsent (t * testing.T ) {
94
94
it .MapTester (t , func (t * testing.T , m * hz.Map ) {
95
95
targetValue := "value"
96
- if _ , err := m .PutIfAbsent (context .Background (), "key" , targetValue ); err != nil {
96
+ v , err := m .PutIfAbsent (context .Background (), "key" , targetValue )
97
+ if err != nil {
97
98
t .Fatal (err )
98
99
}
100
+ it .AssertEquals (t , nil , v )
99
101
it .AssertEquals (t , targetValue , it .MustValue (m .Get (context .Background (), "key" )))
100
- if _ , err := m .PutIfAbsent (context .Background (), "key" , "another-value" ); err != nil {
102
+ v , err = m .PutIfAbsent (context .Background (), "key" , "another-value" )
103
+ if err != nil {
101
104
t .Fatal (err )
102
105
}
106
+ it .AssertEquals (t , "value" , v )
103
107
it .AssertEquals (t , targetValue , it .MustValue (m .Get (context .Background (), "key" )))
104
108
})
105
109
}
106
110
107
111
func TestMap_PutIfAbsentWithTTL (t * testing.T ) {
108
112
it .MapTester (t , func (t * testing.T , m * hz.Map ) {
109
113
targetValue := "value"
110
- if _ , err := m .PutIfAbsentWithTTL (context .Background (), "key" , targetValue , 1 * time .Second ); err != nil {
114
+ v , err := m .PutIfAbsentWithTTL (context .Background (), "key" , targetValue , 1 * time .Second )
115
+ if err != nil {
111
116
t .Fatal (err )
112
117
}
118
+ assert .Equal (t , nil , v )
113
119
assert .Equal (t , targetValue , it .MustValue (m .Get (context .Background (), "key" )))
114
120
it .Eventually (t , func () bool {
115
121
return it .MustValue (m .Get (context .Background (), "key" )) == nil
@@ -120,9 +126,11 @@ func TestMap_PutIfAbsentWithTTL(t *testing.T) {
120
126
func TestMap_PutIfAbsentWithTTLAndMaxIdle (t * testing.T ) {
121
127
it .MapTester (t , func (t * testing.T , m * hz.Map ) {
122
128
targetValue := "value"
123
- if _ , err := m .PutIfAbsentWithTTLAndMaxIdle (context .Background (), "key" , targetValue , 1 * time .Second , 1 * time .Second ); err != nil {
129
+ v , err := m .PutIfAbsentWithTTLAndMaxIdle (context .Background (), "key" , targetValue , 1 * time .Second , 1 * time .Second )
130
+ if err != nil {
124
131
t .Fatal (err )
125
132
}
133
+ assert .Equal (t , nil , v )
126
134
assert .Equal (t , targetValue , it .MustValue (m .Get (context .Background (), "key" )))
127
135
it .Eventually (t , func () bool {
128
136
return it .MustValue (m .Get (context .Background (), "key" )) == nil
0 commit comments