1
1
mirror of https://gitea.com/gitea/tea synced 2024-11-27 01:27:40 +01:00
tea/cmd/labels/create_test.go
6543 f445ac7521 Refactor: apply new internal structurs (#206)
fix lint

fix lint

Move print TrackedTimesList to print package

Move AbsPathWithExpansion to utils/path.go

rename module intern to config

Move Subcomands into it's own Packages

Split times subcomands into own sourcefiles

Split repos subcomands into own sourcefiles

Split releases subcomands into own sourcefiles

Split pulls subcomands into own sourcefiles

Split milestones subcomands into own sourcefiles

Split login subcomands into own sourcefiles

Split labels subcomands into own sourcefiles

split issues subcomands into own sourcefiles

mv

Move Interactive Login Creation to interact package

Move Add Login function to intern/login.go

apply from review

lint: add description to exported func

smal nits

Move DetailViews stdout print func to print package

Refactor:
* Move Config & Login routines into intern package
* rename global var in cmd
* Move help func to utils

Co-authored-by: 6543 <6543@obermui.de>
Reviewed-on: https://gitea.com/gitea/tea/pulls/206
Reviewed-by: Norwin <noerw@noreply.gitea.io>
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
2020-09-30 05:11:33 +00:00

53 lines
1.3 KiB
Go

// Copyright 2019 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
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))
var 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++
}
}