synctest.Wait()
require.Equal(t, "WhatsApp is linked and disconnected since "+time.Now().Format(whatsappTimeLayout)+".", test.whatsapp.Status())
- require.Equal(t, "first connect failed, retrying: network unavailable\n", test.logs.String())
+ require.Equal(t, "<4>first connect failed, retrying: network unavailable\n", test.logs.String())
})
}
time.Sleep(10 * time.Minute)
synctest.Wait()
require.Len(t, test.fake.Connections(), 11)
- require.Equal(t, "first connect failed, retrying: network unavailable\nconnected again after "+durationText(outage)+"\n", test.logs.String())
+ require.Equal(t, "<4>first connect failed, retrying: network unavailable\n<6>connected again after="+durationText(outage)+"\n", test.logs.String())
})
}
time.Sleep(whatsappRetryLimit)
synctest.Wait()
require.Len(t, test.fake.Connections(), 2)
- require.Equal(t, "first connect failed, retrying: network unavailable\nconnected again after 2s\n", test.logs.String())
+ require.Equal(t, "<4>first connect failed, retrying: network unavailable\n<6>connected again after=2s\n", test.logs.String())
})
}
require.True(t, fake.Emit(&events.Connected{}))
require.Equal(t, []string{
- "connected",
- "disconnected, retrying",
- "connected again after 1m25s",
+ "<6>connected",
+ "<4>disconnected, retrying",
+ "<6>connected again after=1m25s",
}, strings.Split(strings.TrimSuffix(logs.String(), "\n"), "\n"))
require.NotContains(t, logs.String(), whatsappTestNumber)
require.NotContains(t, logs.String(), whatsappTestLID)
func TestWhatsAppPairsWithACode(t *testing.T) {
dir := t.TempDir()
- whatsapp, fake, _ := whatsappStartTest(t, dir, newTestClock())
+ whatsapp, fake, logs := whatsappStartTest(t, dir, newTestClock())
server := newModelFake(t)
socket, memory := daemonStartTestWithWhatsApp(t, server, nil, whatsapp)
asking := terminalStartTestClient(t, socket)
require.Equal(t, "[connected to OneChat]\n", other.Output())
require.Zero(t, server.Calls())
require.Equal(t, []string{"WhatsApp is linked."}, whatsappTestLogTexts(t, memory))
+ require.Equal(t, "<6>linked\n", logs.String())
info, err := os.Stat(filepath.Join(dir, whatsappDirName))
require.NoError(t, err)
dir := t.TempDir()
whatsappTestSession(t, dir, true)
- whatsapp, fake, _ := whatsappStartTest(t, dir, newTestClock())
+ whatsapp, fake, logs := whatsappStartTest(t, dir, newTestClock())
fake.logoutErr = tc.logoutErr
socket, memory := daemonStartTestWithWhatsApp(t, newModelFake(t), nil, whatsapp)
client := terminalStartTestClient(t, socket)
client.Type("/whatsapp unlink")
client.WaitFor(t, tc.answer)
require.Equal(t, 1, fake.Logouts())
+ require.Equal(t, "<6>unlinked\n", logs.String())
require.NoFileExists(t, filepath.Join(dir, whatsappDirName, whatsappSessionFileName))
require.Equal(t, "WhatsApp is not linked. Run /whatsapp pair PHONE to link it.", whatsapp.Status())
require.Equal(t, []string{"WhatsApp is unlinked."}, whatsappTestLogTexts(t, memory))
dir := t.TempDir()
whatsappTestSession(t, dir, true)
- whatsapp, fake, _ := whatsappStartTest(t, dir, newTestClock())
+ whatsapp, fake, logs := whatsappStartTest(t, dir, newTestClock())
telegram := newTelegramFake(t)
bot, _ := telegramStartTestBot(t, telegram)
socket, memory := daemonStartTestWithWhatsApp(t, newModelFake(t), bot, whatsapp)
notice := "WhatsApp was unlinked from the phone. Run /whatsapp pair PHONE to link it again."
client.WaitFor(t, notice)
telegramWaitForSent(t, telegram, notice)
+ require.Equal(t, "<3>logged out by the phone, run /whatsapp pair PHONE\n", logs.String())
require.NoFileExists(t, filepath.Join(dir, whatsappDirName, whatsappSessionFileName))
require.Equal(t, "WhatsApp is not linked. Run /whatsapp pair PHONE to link it.", whatsapp.Status())
require.Equal(t, []string{"WhatsApp was unlinked from the phone."}, whatsappTestLogTexts(t, memory))
dir := t.TempDir()
whatsappTestSession(t, dir, true)
- whatsapp, fake, _ := whatsappStartTest(t, dir, newTestClock())
+ whatsapp, fake, logs := whatsappStartTest(t, dir, newTestClock())
socket, _ := daemonStartTestWithWhatsApp(t, newModelFake(t), nil, whatsapp)
client := terminalStartTestClient(t, socket)
client.WaitFor(t, "[connected to OneChat]")
require.True(t, fake.Emit(&events.StreamReplaced{}))
client.WaitFor(t, "WhatsApp is disconnected and does not connect again by itself: stream replaced. Restart the daemon to try again.")
+ require.Equal(t, "<3>disconnected for good, restart to retry: stream replaced\n", logs.String())
}
func TestWhatsAppLogsNoOwnNumber(t *testing.T) {
require.Eventually(t, func() bool {
return logs.String() != ""
}, 10*time.Second, time.Millisecond)
- require.Equal(t, "first connect failed, retrying: no route for OWN@s.whatsapp.net and OWN@lid\n", logs.String())
+ require.Equal(t, "<4>first connect failed, retrying: no route for OWN@s.whatsapp.net and OWN@lid\n", logs.String())
}
func TestWhatsAppPhone(t *testing.T) {