X-Git-Url: https://git.giacomolli.uk/onechat/blobdiff_plain/d7bc0a6ac452bfc646610fdfd7c8eccb5c55218f..9301f77a5709fe7daea3a71f8dd072c6cd7df4fe:/daemon_message_test.go?ds=sidebyside diff --git a/daemon_message_test.go b/daemon_message_test.go index dd3906b..cfb41c6 100644 --- a/daemon_message_test.go +++ b/daemon_message_test.go @@ -251,8 +251,21 @@ func TestNotificationBatchesKeepAcceptanceOrder(t *testing.T) { } func TestNotificationRecoversItsPreparedLogIDWithoutAnotherAppend(t *testing.T) { - for _, appended := range []bool{false, true} { - t.Run(fmt.Sprintf("log append completed %t", appended), func(t *testing.T) { + testCases := []struct { + name string + appended bool + }{ + { + name: "recovers a saved ID before the log append", + }, + { + name: "reuses the log entry after the append", + appended: true, + }, + } + + for _, tc := range testCases { + t.Run(tc.name, func(t *testing.T) { directory := t.TempDir() server := newModelFake(t) server.reply = func(w http.ResponseWriter, _ ModelFakeCall) { @@ -267,7 +280,7 @@ func TestNotificationRecoversItsPreparedLogIDWithoutAnotherAppend(t *testing.T) }) require.NoError(t, err) - if appended { + if tc.appended { require.NoError(t, first.messages.Notifications(first.loops[0])) } else { id := 0