fix: address verified review findings (actions-workflows-values-1)

Signed-off-by: bircni <bircni@icloud.com>
This commit is contained in:
bircni committed 2026-10-18 17:40:06 +02:00
1 parent 401650b489
commit 432d139071
12 files changed
+268 -34

No files matched your search

+30
View File
@@ -347,3 +347,33 @@ func TestAccountCompletionUsesInstanceOfRepository(t *testing.T) {
require.Equal(t, []string{"adam\thttps://a.example.org", "alice\thttps://a.example.org (active)"}, values, command)
}
}
func TestActionValueCompletionOutsideARepository(t *testing.T) {
server := newAuthenticatedServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
switch r.URL.Path {
case "/api/v1/orgs/acme/actions/variables":
_, _ = w.Write([]byte(`[{"name":"REGION","data":"eu"}]`))
case "/api/v1/user/actions/variables":
_, _ = w.Write([]byte(`[{"name":"HOME_REGION","data":"eu"}]`))
default:
t.Errorf("unexpected request %s", r.URL.Path)
w.WriteHeader(http.StatusTeapot)
}
}))
defer server.Close()
deps, _, _ := serverDeps(t, server.URL)
a := &application{deps: deps}
cmd := &cobra.Command{}
cmd.SetContext(context.Background())
for name, tc := range map[string]struct {
scope services.ActionScope
want []string
}{
"organization": {services.ActionScope{Organization: "acme"}, []string{"REGION"}},
"account": {services.ActionScope{Account: true}, []string{"HOME_REGION"}},
"repository": {services.ActionScope{}, nil},
} {
values, _ := a.completeVariables(func() services.ActionScope { return tc.scope })(cmd, nil, "")
require.ElementsMatch(t, tc.want, values, name)
}
}