(t *testing.T)
| 97 | } |
| 98 | |
| 99 | func TestCutOutTerminatedPath(t *testing.T) { |
| 100 | tests := []struct { |
| 101 | name string |
| 102 | subPath string |
| 103 | marker string |
| 104 | expectedPath string |
| 105 | expectedFound bool |
| 106 | }{ |
| 107 | { |
| 108 | name: "basic path with marker", |
| 109 | subPath: "/space1/space2/+/authToken", |
| 110 | marker: "/+", |
| 111 | expectedPath: "/space1/space2", |
| 112 | expectedFound: true, |
| 113 | }, |
| 114 | { |
| 115 | name: "git suffix", |
| 116 | subPath: "/space1/space2.git", |
| 117 | marker: ".git", |
| 118 | expectedPath: "/space1/space2", |
| 119 | expectedFound: true, |
| 120 | }, |
| 121 | { |
| 122 | name: "git suffix with trailing slash", |
| 123 | subPath: "/space1/space2.git/", |
| 124 | marker: ".git", |
| 125 | expectedPath: "/space1/space2", |
| 126 | expectedFound: true, |
| 127 | }, |
| 128 | { |
| 129 | name: "multiple markers 1", |
| 130 | subPath: "/foo/bar/+/artifact/myartifact/+", |
| 131 | marker: "/+", |
| 132 | expectedPath: "/foo/bar", |
| 133 | expectedFound: true, |
| 134 | }, |
| 135 | { |
| 136 | name: "multiple markers 2", |
| 137 | subPath: "/foo/bar/+/artifact/myartifact/+/", |
| 138 | marker: "/+", |
| 139 | expectedPath: "/foo/bar", |
| 140 | expectedFound: true, |
| 141 | }, |
| 142 | { |
| 143 | name: "mixed markers 1", |
| 144 | subPath: "/foo/bar/+artifact/myartifact/+", |
| 145 | marker: "/+", |
| 146 | expectedPath: "/foo/bar/+artifact/myartifact", |
| 147 | expectedFound: true, |
| 148 | }, |
| 149 | { |
| 150 | name: "mixed markers 2", |
| 151 | subPath: "/foo/bar/repo.git/myfile1/myfile2/.gitignore", |
| 152 | marker: ".git", |
| 153 | expectedPath: "/foo/bar/repo", |
| 154 | expectedFound: true, |
| 155 | }, |
| 156 | { |
nothing calls this directly
no test coverage detected
searching dependent graphs…