| 796 | } |
| 797 | |
| 798 | func TestMapRemoteURL(t *testing.T) { |
| 799 | repo := test.NewRepo(t) |
| 800 | repo.Pushd() |
| 801 | defer func() { |
| 802 | repo.Popd() |
| 803 | repo.Cleanup() |
| 804 | }() |
| 805 | cfg := repo.GitConfig() |
| 806 | cfg.SetLocal("remote.foo.url", "https://github.com/git-lfs/git-lfs.git") |
| 807 | cfg.SetLocal("remote.bar.url", "https://github.com/git-lfs/wildmatch.git") |
| 808 | cfg.SetLocal("remote.bar.pushurl", "https://github.com/git-lfs/pktline.git") |
| 809 | |
| 810 | tests := []struct { |
| 811 | url string |
| 812 | push bool |
| 813 | match bool |
| 814 | val string |
| 815 | }{ |
| 816 | { |
| 817 | "https://github.com/git-lfs/git-lfs.git", |
| 818 | false, |
| 819 | true, |
| 820 | "foo", |
| 821 | }, |
| 822 | { |
| 823 | "https://github.com/git-lfs/git-lfs.git", |
| 824 | true, |
| 825 | true, |
| 826 | "foo", |
| 827 | }, |
| 828 | { |
| 829 | "https://github.com/git-lfs/wildmatch.git", |
| 830 | false, |
| 831 | true, |
| 832 | "bar", |
| 833 | }, |
| 834 | { |
| 835 | "https://github.com/git-lfs/pktline.git", |
| 836 | true, |
| 837 | true, |
| 838 | "bar", |
| 839 | }, |
| 840 | { |
| 841 | "https://github.com/git-lfs/pktline.git", |
| 842 | false, |
| 843 | false, |
| 844 | "https://github.com/git-lfs/pktline.git", |
| 845 | }, |
| 846 | { |
| 847 | "https://github.com/git/git.git", |
| 848 | true, |
| 849 | false, |
| 850 | "https://github.com/git/git.git", |
| 851 | }, |
| 852 | } |
| 853 | for _, test := range tests { |
| 854 | val, ok := MapRemoteURL(test.url, test.push) |
| 855 | assert.Equal(t, ok, test.match) |