change impl of last fix
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
ycc
2026-02-28 21:22:15 +01:00
parent cd9ee54f6d
commit b722a916a9
2 changed files with 32 additions and 25 deletions

View File

@@ -88,15 +88,13 @@ func storeTestMessage(t *testing.T, peer *client.Peer, text string) {
// pushAndMarkSent pushes a send job for the given peer and marks it as delivered
// by the given server. Returns the job after the status update.
// It mirrors the correct app usage: read MessageDbFile/MessageDbId from
// peer.LastMessage right after storing (i.e. from CreateAndStoreUserMessage's
// dbFile/dbId return values).
// It mirrors the correct app usage: call GetPeerLastMessageDbInfo immediately
// after storing to populate MessageDbFile and MessageDbId on the job.
func pushAndMarkSent(t *testing.T, dir string, peer *client.Peer, srv client.Server) *client.SendJob {
t.Helper()
require.NotNil(t, peer.LastMessage, "pushAndMarkSent: call storeTestMessage first")
dbFile := peer.LastMessage.Dbfile
dbId := peer.LastMessage.Dbid
dbFile, dbId, errTxt, err := GetPeerLastMessageDbInfo(peer.Uid)
require.NoError(t, err, errTxt)
msgFile := filepath.Join(dir, fmt.Sprintf("msg-%d.bin", dbId))
require.NoError(t, os.WriteFile(msgFile, []byte("packed-server-message"), 0600))
@@ -178,7 +176,9 @@ func TestProcessSentMessages_SkipsJobWithoutDeliveryInfo(t *testing.T) {
require.NoError(t, id.Peers.StorePeer(peer))
storeTestMessage(t, peer, "incomplete job")
require.NotNil(t, peer.LastMessage)
dbFile, dbId, errTxt, err := GetPeerLastMessageDbInfo(peer.Uid)
require.NoError(t, err, errTxt)
msgFile := filepath.Join(dir, "msg.bin")
require.NoError(t, os.WriteFile(msgFile, []byte("packed"), 0600))
@@ -186,8 +186,8 @@ func TestProcessSentMessages_SkipsJobWithoutDeliveryInfo(t *testing.T) {
require.NoError(t, client.PushSendJob(dir, &client.SendJob{
Queue: peer.Uid,
File: msgFile,
MessageDbFile: peer.LastMessage.Dbfile,
MessageDbId: peer.LastMessage.Dbid,
MessageDbFile: dbFile,
MessageDbId: dbId,
Servers: []client.Server{{Url: "http://test-server.example"}},
Timeout: 60,
}))