|
3 | 3 | createCargoToolConfig, |
4 | 4 | createDotnetToolConfig, |
5 | 5 | createGemToolConfig, |
| 6 | + createGithubToolConfig, |
6 | 7 | createGoToolConfig, |
7 | 8 | createNpmToolConfig, |
8 | 9 | createPipxToolConfig, |
@@ -104,6 +105,98 @@ describe('modules/manager/mise/backends', () => { |
104 | 105 | }); |
105 | 106 | }); |
106 | 107 |
|
| 108 | + describe('createGithubToolConfig()', () => { |
| 109 | + it('should create a tooling config with empty options', () => { |
| 110 | + expect( |
| 111 | + createGithubToolConfig('BurntSushi/ripgrep', '14.1.1', {}), |
| 112 | + ).toStrictEqual({ |
| 113 | + packageName: 'BurntSushi/ripgrep', |
| 114 | + datasource: 'github-releases', |
| 115 | + currentValue: '14.1.1', |
| 116 | + }); |
| 117 | + }); |
| 118 | + |
| 119 | + it('should not set extractVersion if the version has leading v', () => { |
| 120 | + expect(createGithubToolConfig('cli/cli', 'v2.64.0', {})).toStrictEqual({ |
| 121 | + packageName: 'cli/cli', |
| 122 | + datasource: 'github-releases', |
| 123 | + currentValue: 'v2.64.0', |
| 124 | + }); |
| 125 | + }); |
| 126 | + |
| 127 | + it('should set extractVersion with custom version_prefix', () => { |
| 128 | + expect( |
| 129 | + createGithubToolConfig('some/repo', '1.0.0', { |
| 130 | + version_prefix: 'release-', |
| 131 | + }), |
| 132 | + ).toStrictEqual({ |
| 133 | + packageName: 'some/repo', |
| 134 | + datasource: 'github-releases', |
| 135 | + currentValue: '1.0.0', |
| 136 | + extractVersion: '^release\\-(?<version>.+)', |
| 137 | + }); |
| 138 | + }); |
| 139 | + |
| 140 | + it('should set extractVersion with version_prefix even if version has leading v', () => { |
| 141 | + expect( |
| 142 | + createGithubToolConfig('some/repo', 'v1.0.0', { |
| 143 | + version_prefix: 'version-', |
| 144 | + }), |
| 145 | + ).toStrictEqual({ |
| 146 | + packageName: 'some/repo', |
| 147 | + datasource: 'github-releases', |
| 148 | + currentValue: 'v1.0.0', |
| 149 | + extractVersion: '^version\\-(?<version>.+)', |
| 150 | + }); |
| 151 | + }); |
| 152 | + |
| 153 | + it('should handle empty version_prefix with version not having v', () => { |
| 154 | + expect( |
| 155 | + createGithubToolConfig('some/repo', '1.0.0', { version_prefix: '' }), |
| 156 | + ).toStrictEqual({ |
| 157 | + packageName: 'some/repo', |
| 158 | + datasource: 'github-releases', |
| 159 | + currentValue: '1.0.0', |
| 160 | + }); |
| 161 | + }); |
| 162 | + |
| 163 | + it('should handle empty version_prefix with version having v', () => { |
| 164 | + expect( |
| 165 | + createGithubToolConfig('some/repo', 'v1.0.0', { version_prefix: '' }), |
| 166 | + ).toStrictEqual({ |
| 167 | + packageName: 'some/repo', |
| 168 | + datasource: 'github-releases', |
| 169 | + currentValue: 'v1.0.0', |
| 170 | + }); |
| 171 | + }); |
| 172 | + |
| 173 | + it('should escape special regex characters in version_prefix', () => { |
| 174 | + expect( |
| 175 | + createGithubToolConfig('some/repo', '1.0.0', { |
| 176 | + version_prefix: 'v1.0+', |
| 177 | + }), |
| 178 | + ).toStrictEqual({ |
| 179 | + packageName: 'some/repo', |
| 180 | + datasource: 'github-releases', |
| 181 | + currentValue: '1.0.0', |
| 182 | + extractVersion: '^v1\\.0\\+(?<version>.+)', |
| 183 | + }); |
| 184 | + }); |
| 185 | + |
| 186 | + it('should escape brackets and parentheses in version_prefix', () => { |
| 187 | + expect( |
| 188 | + createGithubToolConfig('some/repo', '1.0.0', { |
| 189 | + version_prefix: 'prefix[test](v)', |
| 190 | + }), |
| 191 | + ).toStrictEqual({ |
| 192 | + packageName: 'some/repo', |
| 193 | + datasource: 'github-releases', |
| 194 | + currentValue: '1.0.0', |
| 195 | + extractVersion: '^prefix\\[test\\]\\(v\\)(?<version>.+)', |
| 196 | + }); |
| 197 | + }); |
| 198 | + }); |
| 199 | + |
107 | 200 | describe('createGoToolConfig()', () => { |
108 | 201 | it('should create a tooling config', () => { |
109 | 202 | expect(createGoToolConfig('github.com/DarthSim/hivemind')).toStrictEqual({ |
|
0 commit comments