forked from Gitlink/gitlink-cli
44 lines
1.1 KiB
Go
44 lines
1.1 KiB
Go
package daemon
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/gitlink-org/gitlink-cli/shortcuts/common"
|
|
wf "github.com/gitlink-org/gitlink-cli/shortcuts/workflow"
|
|
)
|
|
|
|
func TestBuildDaemonArgsSkipsOwnerRepoForExplicitMultiRepo(t *testing.T) {
|
|
wfDef := &wf.WorkflowDef{
|
|
Name: "multi-repo",
|
|
}
|
|
ctx := &common.RuntimeContext{
|
|
Owner: "ignored",
|
|
Repo: "ignored",
|
|
Args: map[string]string{
|
|
"repos": "org/backend,org/frontend",
|
|
"release": "v1.4.0",
|
|
},
|
|
}
|
|
|
|
args := BuildDaemonArgs(ctx, wfDef, 24*time.Hour, "no-ai")
|
|
if stringSliceContains(args, "--owner") || stringSliceContains(args, "--repo") {
|
|
t.Fatalf("explicit multi-repo daemon args should not include owner/repo: %v", args)
|
|
}
|
|
if !stringSliceContains(args, "--repos") || !stringSliceContains(args, "org/backend,org/frontend") {
|
|
t.Fatalf("daemon args missing repos: %v", args)
|
|
}
|
|
if !stringSliceContains(args, "--release") || !stringSliceContains(args, "v1.4.0") {
|
|
t.Fatalf("daemon args missing release: %v", args)
|
|
}
|
|
}
|
|
|
|
func stringSliceContains(items []string, want string) bool {
|
|
for _, item := range items {
|
|
if item == want {
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
}
|