mirror of
https://code.forgejo.org/forgejo/runner.git
synced 2024-11-28 09:18:54 +03:00
db662b3690
- Removed `deadcode`, `structcheck`, and `varcheck` linters from `.golangci.yml` - Fixed a typo in a comment in `daemon.go` - Renamed `defaultActionsUrl` to `defaultActionsURL` in `exec.go` - Removed unnecessary else clause in `exec.go` and `runner.go` - Simplified variable initialization in `exec.go` - Changed function name from `getHttpClient` to `getHTTPClient` in `http.go` - Removed unnecessary else clause in `labels_test.go` Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com> Reviewed-on: https://gitea.com/gitea/act_runner/pulls/289 Co-authored-by: Bo-Yi Wu <appleboy.tw@gmail.com> Co-committed-by: Bo-Yi Wu <appleboy.tw@gmail.com>
63 lines
1 KiB
Go
63 lines
1 KiB
Go
// Copyright 2023 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package labels
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
"gotest.tools/v3/assert"
|
|
)
|
|
|
|
func TestParse(t *testing.T) {
|
|
tests := []struct {
|
|
args string
|
|
want *Label
|
|
wantErr bool
|
|
}{
|
|
{
|
|
args: "ubuntu:docker://node:18",
|
|
want: &Label{
|
|
Name: "ubuntu",
|
|
Schema: "docker",
|
|
Arg: "//node:18",
|
|
},
|
|
wantErr: false,
|
|
},
|
|
{
|
|
args: "ubuntu:host",
|
|
want: &Label{
|
|
Name: "ubuntu",
|
|
Schema: "host",
|
|
Arg: "",
|
|
},
|
|
wantErr: false,
|
|
},
|
|
{
|
|
args: "ubuntu",
|
|
want: &Label{
|
|
Name: "ubuntu",
|
|
Schema: "host",
|
|
Arg: "",
|
|
},
|
|
wantErr: false,
|
|
},
|
|
{
|
|
args: "ubuntu:vm:ubuntu-18.04",
|
|
want: nil,
|
|
wantErr: true,
|
|
},
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.args, func(t *testing.T) {
|
|
got, err := Parse(tt.args)
|
|
if tt.wantErr {
|
|
require.Error(t, err)
|
|
return
|
|
}
|
|
require.NoError(t, err)
|
|
assert.DeepEqual(t, got, tt.want)
|
|
})
|
|
}
|
|
}
|