Test that the config retrieved from the context is a reference and there are no consistency issues with it getting out of sync
(t *testing.T)
| 2967 | |
| 2968 | // Test that the config retrieved from the context is a reference and there are no consistency issues with it getting out of sync |
| 2969 | func TestCtxConfigIsReference(t *testing.T) { |
| 2970 | // Setup |
| 2971 | markTestForSharding(t, 11) |
| 2972 | tester := zshTester{} |
| 2973 | defer testutils.BackupAndRestore(t)() |
| 2974 | installHishtory(t, tester, "") |
| 2975 | |
| 2976 | // Get two copies of the conifg |
| 2977 | ctx := hctx.MakeContext() |
| 2978 | c1 := hctx.GetConf(ctx) |
| 2979 | c2 := hctx.GetConf(ctx) |
| 2980 | require.Equal(t, *c1, *c2) |
| 2981 | |
| 2982 | // Change one and check that the other is changed |
| 2983 | c1.LastSavedHistoryLine = "foobar" |
| 2984 | require.Equal(t, c1.LastSavedHistoryLine, "foobar") |
| 2985 | require.Equal(t, c2.LastSavedHistoryLine, "foobar") |
| 2986 | |
| 2987 | // Persist that one, and then get the config again, and that one should also contain the change |
| 2988 | require.NoError(t, hctx.SetConfig(c1)) |
| 2989 | c3 := hctx.GetConf(ctx) |
| 2990 | require.Equal(t, *c1, *c3) |
| 2991 | require.Equal(t, c1.LastSavedHistoryLine, "foobar") |
| 2992 | require.Equal(t, c2.LastSavedHistoryLine, "foobar") |
| 2993 | require.Equal(t, c3.LastSavedHistoryLine, "foobar") |
| 2994 | } |
| 2995 | |
| 2996 | func testMultipleUsers(t *testing.T, tester shellTester) { |
| 2997 | defer testutils.BackupAndRestore(t)() |
nothing calls this directly
no test coverage detected