(t *testing.T)
| 258 | } |
| 259 | |
| 260 | func TestSharedState_KeyNamespacing(t *testing.T) { |
| 261 | t.Parallel() |
| 262 | |
| 263 | store := newSharedStateMemoryStorage(t) |
| 264 | appOne := New(Config{AppName: "app-one", SharedStorage: store}) |
| 265 | appTwo := New(Config{AppName: "app-two", SharedStorage: store}) |
| 266 | |
| 267 | err := appOne.SharedState().SetJSON("same-key", Map{"app": 1}, time.Minute) |
| 268 | require.NoError(t, err) |
| 269 | err = appTwo.SharedState().SetJSON("same-key", Map{"app": 2}, time.Minute) |
| 270 | require.NoError(t, err) |
| 271 | |
| 272 | var outOne map[string]int |
| 273 | _, found, err := appOne.SharedState().GetJSON("same-key", &outOne) |
| 274 | require.NoError(t, err) |
| 275 | require.True(t, found) |
| 276 | require.Equal(t, 1, outOne["app"]) |
| 277 | |
| 278 | var outTwo map[string]int |
| 279 | _, found, err = appTwo.SharedState().GetJSON("same-key", &outTwo) |
| 280 | require.NoError(t, err) |
| 281 | require.True(t, found) |
| 282 | require.Equal(t, 2, outTwo["app"]) |
| 283 | } |
| 284 | |
| 285 | func TestSharedState_KeyNamespacingWithOverlappingPrefixes(t *testing.T) { |
| 286 | t.Parallel() |
nothing calls this directly
no test coverage detected