1
0
mirror of https://github.com/badges/shields.git synced 2026-01-26 16:01:35 +03:00
Files
shields/services/gitlab/gitlab-go-mod.tester.js
Olivier Sechet 0c9f64ef52 feat: Add GitLab go.mod Go version service (#11312)
This adds a new service that works the same way as the github-go-mod service but with GitLab. The service will get the go version from the go.mod file in the specified project.

- Tests have been added to work with a stable project ([GitLab Runner](https://gitlab.com/gitlab-org/gitlab-runner)).
- Code has been formatted with prettier.
2025-09-14 11:15:36 +00:00

30 lines
1.0 KiB
JavaScript

import { isVPlusDottedVersionAtLeastOne } from '../test-validators.js'
import { createServiceTester } from '../tester.js'
export const t = await createServiceTester()
const user = 'gitlab-org'
const repo = 'gitlab-runner'
t.create('go version in root')
.get(`/${user}/${repo}.json`)
.expectBadge({ label: 'Go', message: isVPlusDottedVersionAtLeastOne })
t.create('go version in root (branch)')
.get(`/${user}/${repo}/main.json`)
.expectBadge({ label: 'Go@main', message: isVPlusDottedVersionAtLeastOne })
t.create('project not found')
.get('/some-project/that-doesnt-exist.json')
.expectBadge({ label: 'Go', message: 'project or file not found' })
t.create('go version in subdirectory')
.get(`/${user}/${repo}/main.json?filename=helpers/runner_wrapper/api/go.mod`)
.expectBadge({
label: 'Go@main',
message: isVPlusDottedVersionAtLeastOne,
})
t.create('file not found')
.get(`/${user}/${repo}/main.json?filename=nonexistent/go.mod`)
.expectBadge({ label: 'Go', message: 'project or file not found' })