package whatsapp import ( "context" "bytes" "log" "os" "strings" "testing" ) func TestPostContactLogsErrorOnFailure(t *testing.T) { // Capture log output. var buf bytes.Buffer log.SetOutput(&buf) defer log.SetOutput(os.Stderr) // Create adapter with invalid endpoint (connection refused). adapter := &WhatsmeowAdapter{ goEndpoint: "http://localhost:1", internalSecret: "test-secret", } contact := Contact{ Phone: "5511999999999", Name: "Test", Message: "test message", } adapter.postContact(context.Background(), 1, contact, "test-msg-id-123") output := buf.String() if !strings.Contains(output, "postContact") { t.Errorf("expected log to contain 'postContact', got: %s", output) } }