(t *testing.T)
| 807 | } |
| 808 | |
| 809 | func TestStableSourceKey(t *testing.T) { |
| 810 | t.Parallel() |
| 811 | |
| 812 | tests := []struct { |
| 813 | name string |
| 814 | key string |
| 815 | want string |
| 816 | }{ |
| 817 | { |
| 818 | name: "strips query from url key", |
| 819 | key: url.QueryEscape("http://localhost:7777/gordon-agent?gordonTag=v9-light&desktopVersion=4.81.0&origin=desktop"), |
| 820 | want: "http://localhost:7777/gordon-agent", |
| 821 | }, |
| 822 | { |
| 823 | name: "another variant normalises to the same identity", |
| 824 | key: url.QueryEscape("http://localhost:7777/gordon-agent?gordonTag=v9-dev&desktopVersion=4.81.0&origin=desktop"), |
| 825 | want: "http://localhost:7777/gordon-agent", |
| 826 | }, |
| 827 | { |
| 828 | name: "strips all query params, keeping the path identity", |
| 829 | key: url.QueryEscape("http://localhost:7777/gordon-agent?team=blue&gordonTag=v9"), |
| 830 | want: "http://localhost:7777/gordon-agent", |
| 831 | }, |
| 832 | { |
| 833 | name: "strips fragment as well", |
| 834 | key: url.QueryEscape("http://localhost:7777/gordon-agent?gordonTag=v9#section"), |
| 835 | want: "http://localhost:7777/gordon-agent", |
| 836 | }, |
| 837 | { |
| 838 | name: "distinct paths keep distinct identities", |
| 839 | key: url.QueryEscape("http://localhost:7777/other-agent?gordonTag=v9"), |
| 840 | want: "http://localhost:7777/other-agent", |
| 841 | }, |
| 842 | { |
| 843 | name: "non-url key is returned unchanged", |
| 844 | key: "docker_gordon.yaml", |
| 845 | want: "docker_gordon.yaml", |
| 846 | }, |
| 847 | { |
| 848 | name: "local file key is returned unchanged", |
| 849 | key: "my-agent", |
| 850 | want: "my-agent", |
| 851 | }, |
| 852 | } |
| 853 | |
| 854 | for _, tt := range tests { |
| 855 | t.Run(tt.name, func(t *testing.T) { |
| 856 | t.Parallel() |
| 857 | |
| 858 | assert.Equal(t, tt.want, StableSourceKey(tt.key)) |
| 859 | }) |
| 860 | } |
| 861 | } |
| 862 | |
| 863 | // TestStableSourceKey_VariantsCollide is the property the resume fallback |
| 864 | // relies on: two source keys that differ only by volatile query parameters |
nothing calls this directly
no test coverage detected