Files
gitea-tea/cmd/labels/create_test.go
techknowlogick 20da414145 Code Cleanup (#869)
- switch to golangci-lint for linting
- switch to gofmpt for formatting
- fix lint and fmt issues that came up from switch to new tools
- upgrade go-sdk to 0.23.2
- support pagination for listing tracked times
- remove `FixPullHeadSha` workaround (upstream fix has been merged for 5+ years at this point)
- standardize on US spelling (previously a mix of US&UK spelling)
- remove some unused code
- reduce some duplication in parsing state and issue type
- reduce some duplication in reading input for secrets and variables
- reduce some duplication with PR Review code
- report error for when yaml parsing fails
- various other misc cleanup

Reviewed-on: https://gitea.com/gitea/tea/pulls/869
Co-authored-by: techknowlogick <techknowlogick@gitea.com>
Co-committed-by: techknowlogick <techknowlogick@gitea.com>
2026-02-02 22:39:26 +00:00

52 lines
1.2 KiB
Go

// Copyright 2019 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package labels
import (
"bufio"
"strings"
"testing"
"github.com/stretchr/testify/assert"
)
func TestParseLabelLine(t *testing.T) {
const labels = `#ededed in progress
#fbca04 kind/breaking ; breaking label
#fc2929 kind/bug
#c5def5 kind/deployment ; deployment label
#000000 in progress ; in progress label
`
scanner := bufio.NewScanner(strings.NewReader(labels))
i := 1
for scanner.Scan() {
line := scanner.Text()
color, name, description := splitLabelLine(line)
switch i {
case 1:
assert.EqualValues(t, "#ededed", color)
assert.EqualValues(t, "in progress", name)
case 2:
assert.EqualValues(t, "#fbca04", color)
assert.EqualValues(t, "kind/breaking", name)
assert.EqualValues(t, "breaking label", description)
case 3:
assert.EqualValues(t, "#fc2929", color)
assert.EqualValues(t, "kind/bug", name)
case 4:
assert.EqualValues(t, "#c5def5", color)
assert.EqualValues(t, "kind/deployment", name)
assert.EqualValues(t, "deployment label", description)
case 5:
assert.EqualValues(t, "#000000", color)
assert.EqualValues(t, "in progress", name)
assert.EqualValues(t, "in progress label", description)
}
i++
}
}