mirror of
https://gitea.com/gitea/act_runner.git
synced 2025-06-15 11:07:13 +02:00
Clarify labels (#69)
The label will follow the format `label[:schema[:args]]`, and the schema will be `host` if it's omitted. So - `ubuntu:docker://node:18`: Run jobs with label `ubuntu` via docker with image `node:18` - `ubuntu:host`: Run jobs with label `ubuntu` on the host directly. - `ubuntu`: Same as `ubuntu:host`. - `ubuntu:vm:ubuntu-latest`: (Just a example, not Implemented) Run jobs with label `ubuntu` via virtual machine with iso `ubuntu-latest`. Reviewed-on: https://gitea.com/gitea/act_runner/pulls/69 Reviewed-by: Zettat123 <zettat123@noreply.gitea.io> Reviewed-by: wxiaoguang <wxiaoguang@noreply.gitea.io>
This commit is contained in:
60
runtime/label_test.go
Normal file
60
runtime/label_test.go
Normal file
@ -0,0 +1,60 @@
|
||||
package runtime
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestParseLabel(t *testing.T) {
|
||||
tests := []struct {
|
||||
args string
|
||||
wantLabel string
|
||||
wantSchema string
|
||||
wantArg string
|
||||
wantErr bool
|
||||
}{
|
||||
{
|
||||
args: "ubuntu:docker://node:18",
|
||||
wantLabel: "ubuntu",
|
||||
wantSchema: "docker",
|
||||
wantArg: "//node:18",
|
||||
wantErr: false,
|
||||
},
|
||||
{
|
||||
args: "ubuntu:host",
|
||||
wantLabel: "ubuntu",
|
||||
wantSchema: "host",
|
||||
wantArg: "",
|
||||
wantErr: false,
|
||||
},
|
||||
{
|
||||
args: "ubuntu",
|
||||
wantLabel: "ubuntu",
|
||||
wantSchema: "host",
|
||||
wantArg: "",
|
||||
wantErr: false,
|
||||
},
|
||||
{
|
||||
args: "ubuntu:vm:ubuntu-18.04",
|
||||
wantLabel: "",
|
||||
wantSchema: "",
|
||||
wantArg: "",
|
||||
wantErr: true,
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.args, func(t *testing.T) {
|
||||
gotLabel, gotSchema, gotArg, err := ParseLabel(tt.args)
|
||||
if (err != nil) != tt.wantErr {
|
||||
t.Errorf("parseLabel() error = %v, wantErr %v", err, tt.wantErr)
|
||||
return
|
||||
}
|
||||
if gotLabel != tt.wantLabel {
|
||||
t.Errorf("parseLabel() gotLabel = %v, want %v", gotLabel, tt.wantLabel)
|
||||
}
|
||||
if gotSchema != tt.wantSchema {
|
||||
t.Errorf("parseLabel() gotSchema = %v, want %v", gotSchema, tt.wantSchema)
|
||||
}
|
||||
if gotArg != tt.wantArg {
|
||||
t.Errorf("parseLabel() gotArg = %v, want %v", gotArg, tt.wantArg)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user