mirror of
https://code.forgejo.org/forgejo/runner.git
synced 2024-11-21 12:17:17 +03:00
added simple test to label update
This commit is contained in:
parent
7abbd84a8a
commit
5660e21fb8
1 changed files with 38 additions and 0 deletions
38
internal/app/run/runner_test.go
Normal file
38
internal/app/run/runner_test.go
Normal file
|
@ -0,0 +1,38 @@
|
|||
package run
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"gitea.com/gitea/act_runner/internal/pkg/labels"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestLabelUpdate(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ls := labels.Labels{}
|
||||
|
||||
initialLabel, err := labels.Parse("testlabel:docker://alpine")
|
||||
assert.Nil(t, err)
|
||||
ls = append(ls, initialLabel)
|
||||
|
||||
newLs := labels.Labels{}
|
||||
|
||||
newLabel, err := labels.Parse("next label:host")
|
||||
assert.Nil(t, err)
|
||||
newLs = append(newLs, initialLabel)
|
||||
newLs = append(newLs, newLabel)
|
||||
|
||||
runner := Runner{
|
||||
labels: ls,
|
||||
}
|
||||
|
||||
assert.Contains(t, runner.labels, initialLabel)
|
||||
assert.NotContains(t, runner.labels, newLabel)
|
||||
|
||||
runner.Update(ctx, newLs)
|
||||
|
||||
assert.Contains(t, runner.labels, initialLabel)
|
||||
assert.Contains(t, runner.labels, newLabel)
|
||||
|
||||
}
|
Loading…
Reference in a new issue