@@ -57,45 +57,45 @@ func TestWithReadMode(t *testing.T) {
5757 ctx := context .Background ()
5858 readPrimaryCtx := WithReadPrimary (ctx )
5959
60- val := readPrimaryCtx .Value (readWriteModeKey )
60+ val := readPrimaryCtx .Value (readWriteModeKey {} )
6161 assert .Equal (t , readPrimaryMode , val )
6262
6363 readReplicaCtx := WithReadReplica (ctx )
64- val = readReplicaCtx .Value (readWriteModeKey )
64+ val = readReplicaCtx .Value (readWriteModeKey {} )
6565 assert .Equal (t , readReplicaMode , val )
6666}
6767
6868func TestWithWriteMode (t * testing.T ) {
6969 ctx := context .Background ()
7070 writeCtx := WithWrite (ctx )
7171
72- val := writeCtx .Value (readWriteModeKey )
72+ val := writeCtx .Value (readWriteModeKey {} )
7373 assert .Equal (t , writeMode , val )
7474}
7575
7676func TestGetReadWriteMode (t * testing.T ) {
7777 t .Run ("valid read-primary mode" , func (t * testing.T ) {
78- ctx := context .WithValue (context .Background (), readWriteModeKey , readPrimaryMode )
78+ ctx := context .WithValue (context .Background (), readWriteModeKey {} , readPrimaryMode )
7979 assert .Equal (t , readPrimaryMode , getReadWriteMode (ctx ))
8080 })
8181
8282 t .Run ("valid read-replica mode" , func (t * testing.T ) {
83- ctx := context .WithValue (context .Background (), readWriteModeKey , readReplicaMode )
83+ ctx := context .WithValue (context .Background (), readWriteModeKey {} , readReplicaMode )
8484 assert .Equal (t , readReplicaMode , getReadWriteMode (ctx ))
8585 })
8686
8787 t .Run ("valid write mode" , func (t * testing.T ) {
88- ctx := context .WithValue (context .Background (), readWriteModeKey , writeMode )
88+ ctx := context .WithValue (context .Background (), readWriteModeKey {} , writeMode )
8989 assert .Equal (t , writeMode , getReadWriteMode (ctx ))
9090 })
9191
9292 t .Run ("invalid mode value (wrong type)" , func (t * testing.T ) {
93- ctx := context .WithValue (context .Background (), readWriteModeKey , "not-a-mode" )
93+ ctx := context .WithValue (context .Background (), readWriteModeKey {} , "not-a-mode" )
9494 assert .Equal (t , notSpecifiedMode , getReadWriteMode (ctx ))
9595 })
9696
9797 t .Run ("invalid mode value (wrong value)" , func (t * testing.T ) {
98- ctx := context .WithValue (context .Background (), readWriteModeKey , readWriteMode ("delete" ))
98+ ctx := context .WithValue (context .Background (), readWriteModeKey {} , readWriteMode ("delete" ))
9999 assert .Equal (t , notSpecifiedMode , getReadWriteMode (ctx ))
100100 })
101101
@@ -107,22 +107,22 @@ func TestGetReadWriteMode(t *testing.T) {
107107
108108func TestUsePrimary (t * testing.T ) {
109109 t .Run ("context with read-replica mode" , func (t * testing.T ) {
110- ctx := context .WithValue (context .Background (), readWriteModeKey , readReplicaMode )
110+ ctx := context .WithValue (context .Background (), readWriteModeKey {} , readReplicaMode )
111111 assert .False (t , usePrimary (ctx ))
112112 })
113113
114114 t .Run ("context with read-primary mode" , func (t * testing.T ) {
115- ctx := context .WithValue (context .Background (), readWriteModeKey , readPrimaryMode )
115+ ctx := context .WithValue (context .Background (), readWriteModeKey {} , readPrimaryMode )
116116 assert .True (t , usePrimary (ctx ))
117117 })
118118
119119 t .Run ("context with write mode" , func (t * testing.T ) {
120- ctx := context .WithValue (context .Background (), readWriteModeKey , writeMode )
120+ ctx := context .WithValue (context .Background (), readWriteModeKey {} , writeMode )
121121 assert .True (t , usePrimary (ctx ))
122122 })
123123
124124 t .Run ("context with invalid mode" , func (t * testing.T ) {
125- ctx := context .WithValue (context .Background (), readWriteModeKey , readWriteMode ("invalid" ))
125+ ctx := context .WithValue (context .Background (), readWriteModeKey {} , readWriteMode ("invalid" ))
126126 assert .True (t , usePrimary (ctx ))
127127 })
128128
@@ -137,6 +137,6 @@ func TestWithModeTwice(t *testing.T) {
137137 ctx = WithReadPrimary (ctx )
138138 writeCtx := WithWrite (ctx )
139139
140- val := writeCtx .Value (readWriteModeKey )
140+ val := writeCtx .Value (readWriteModeKey {} )
141141 assert .Equal (t , writeMode , val )
142142}
0 commit comments