dev vouch dev on at. thats about it atvouch.dev
8
fork

Configure Feed

Select the types of activity you want to include in your feed.

add test case for invalid pulls

authored by

Luna and committed by tangled.org 0df90a8b 3bc0a96b

+82
+82
appview/test/atvouch/tap_handler_test.exs
··· 740 740 assert Atvouch.Membership.one(repo_at_uri) == nil 741 741 end 742 742 743 + test "processes pull record with lexicon-canonical target.repo format", %{port: port} do 744 + {:ok, _pid} = 745 + Atvouch.Tap.Socket.start_link( 746 + uri: "ws://localhost:#{port}/channel", 747 + handler: Atvouch.TapHandler, 748 + password: "123", 749 + name: :"tap_handler_pull_test_#{port}" 750 + ) 751 + 752 + assert_receive {:ws_connected, ws_pid}, 5_000 753 + 754 + author_did = "did:plc:jjiv56ot7d6sgethto3jr3r5" 755 + repo_at_uri = "at://did:plc:nhyitepp3u4u6fcfboegzcjw/sh.tangled.repo/3lkqb2xfney22" 756 + 757 + # No membership exists for this repo, so it should skip gracefully 758 + Atvouch.Test.FakeTapServer.send_event(ws_pid, %{ 759 + "id" => 700, 760 + "type" => "record", 761 + "record" => %{ 762 + "action" => "create", 763 + "did" => author_did, 764 + "rev" => "3mg5rgz3rfw22", 765 + "collection" => "sh.tangled.repo.pull", 766 + "rkey" => "3lkqhyks4nm22", 767 + "record" => %{ 768 + "$type" => "sh.tangled.repo.pull", 769 + "target" => %{ 770 + "repo" => repo_at_uri, 771 + "branch" => "main" 772 + }, 773 + "title" => "Test pull request", 774 + "patch" => "diff --git a/README.md b/README.md", 775 + "patchBlob" => %{"$type" => "blob", "ref" => %{"$link" => "abc"}, "mimeType" => "text/x-patch", "size" => 100}, 776 + "createdAt" => "2026-03-22T10:00:00.000Z" 777 + }, 778 + "cid" => "bafyreihd5owje27fzv5nfbvt3t5hziah74o6gdjgvooqrvlfhnu6xbidpi", 779 + "live" => false 780 + } 781 + }) 782 + 783 + assert_receive {:ws_message, %{"type" => "ack", "id" => 700}}, 5_000 784 + end 785 + 786 + test "skips pull record with missing target repo field", %{port: port} do 787 + {:ok, _pid} = 788 + Atvouch.Tap.Socket.start_link( 789 + uri: "ws://localhost:#{port}/channel", 790 + handler: Atvouch.TapHandler, 791 + password: "123", 792 + name: :"tap_handler_pull_missing_target_test_#{port}" 793 + ) 794 + 795 + assert_receive {:ws_connected, ws_pid}, 5_000 796 + 797 + # Send a pull record with no target field at all 798 + Atvouch.Test.FakeTapServer.send_event(ws_pid, %{ 799 + "id" => 701, 800 + "type" => "record", 801 + "record" => %{ 802 + "action" => "create", 803 + "did" => "did:plc:jjiv56ot7d6sgethto3jr3r5", 804 + "rev" => "3mg5rgz3rfw22", 805 + "collection" => "sh.tangled.repo.pull", 806 + "rkey" => "3lkqhyks4nm22", 807 + "record" => %{ 808 + "$type" => "sh.tangled.repo.pull", 809 + "targetRepo" => "at://did:plc:nhyitepp3u4u6fcfboegzcjw/sh.tangled.repo/3lkqb2xfney22", 810 + "targetBranch" => "main", 811 + "title" => "Flattened format pull", 812 + "patch" => "diff --git a/README.md b/README.md", 813 + "patchBlob" => %{"$type" => "blob", "ref" => %{"$link" => "abc"}, "mimeType" => "text/x-patch", "size" => 100}, 814 + "createdAt" => "2026-03-22T10:00:00.000Z" 815 + }, 816 + "cid" => "bafyreihd5owje27fzv5nfbvt3t5hziah74o6gdjgvooqrvlfhnu6xbidpi", 817 + "live" => false 818 + } 819 + }) 820 + 821 + # Should still ack (skip, not crash) 822 + assert_receive {:ws_message, %{"type" => "ack", "id" => 701}}, 5_000 823 + end 824 + 743 825 test "updates a vouch timestamp from a tap record update event", %{port: port} do 744 826 {:ok, _pid} = 745 827 Atvouch.Tap.Socket.start_link(