MCPcopy Create free account
hub / github.com/cli/cli / filterAcceptanceScripts

Function filterAcceptanceScripts

acceptance/acceptance_test.go:723–743  ·  view source on GitHub ↗
(candidates []acceptanceScript, filtered, hasUserCapability bool)

Source from the content-addressed store, hash-verified

721}
722
723func filterAcceptanceScripts(candidates []acceptanceScript, filtered, hasUserCapability bool) ([]string, string, error) {
724 if filtered && len(candidates) == 0 {
725 return nil, "no selected script belongs to this command directory", nil
726 }
727
728 files := make([]string, 0, len(candidates))
729 for _, candidate := range candidates {
730 if candidate.requiresUserCapability && !hasUserCapability {
731 if filtered {
732 return nil, "", fmt.Errorf("%s requires a token that authenticates a user", candidate.file)
733 }
734 continue
735 }
736 files = append(files, candidate.file)
737 }
738 if len(files) == 0 {
739 return nil, "all scripts require a token that authenticates a user", nil
740 }
741
742 return files, "", nil
743}
744
745func TestFilterAcceptanceScripts(t *testing.T) {
746 userOnly := acceptanceScript{file: "user.txtar", requiresUserCapability: true}

Callers 2

testScriptParamsForFunction · 0.85

Calls 1

ErrorfMethod · 0.65

Tested by

no test coverage detected