mirror of
https://gitea.com/gitea/tea.git
synced 2026-10-26 11:01:25 +01:00
fix: address verified review findings (actions-workflows-values-1)
Signed-off-by: bircni <bircni@icloud.com>
This commit is contained in:
12 files changed
+268
-34
No files matched your search
@@ -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)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user