MCPcopy Create free account
hub / github.com/chainloop-dev/chainloop / TestGetInputArguments

Method TestGetInputArguments

pkg/policies/policies_test.go:810–921  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

808}
809
810func (s *testSuite) TestGetInputArguments() {
811 cases := []struct {
812 name string
813 inputs map[string]string
814 expected map[string]any
815 }{
816 {
817 name: "string input",
818 inputs: map[string]string{"foo": "bar"},
819 expected: map[string]any{"foo": "bar"},
820 },
821 {
822 name: "csv input",
823 inputs: map[string]string{"foo": "bar1,bar2,bar3"},
824 expected: map[string]any{"foo": []string{"bar1", "bar2", "bar3"}},
825 },
826 {
827 name: "csv input with escaped comma",
828 inputs: map[string]string{"foo": "bar1\\,bar2,bar3"},
829 expected: map[string]any{"foo": []string{"bar1,bar2", "bar3"}},
830 },
831 {
832 name: "csv input with empty slots",
833 inputs: map[string]string{"foo": ",bar1,,,bar2,bar3,,"},
834 expected: map[string]any{"foo": []string{"bar1", "bar2", "bar3"}},
835 },
836 {
837 name: "csv input with line feeds",
838 inputs: map[string]string{"foo": "\nbar1,,,bar2,bar3,,"},
839 expected: map[string]any{"foo": []string{"bar1", "bar2", "bar3"}},
840 },
841 {
842 name: "multiline input",
843 inputs: map[string]string{"foo": "\nbar1\nbar2\nbar3\n"},
844 expected: map[string]any{"foo": []string{"bar1", "bar2", "bar3"}},
845 },
846 {
847 name: "multiline input with empty lines",
848 inputs: map[string]string{"foo": "\n\n\nbar1\nbar2\n\nbar3\n"},
849 expected: map[string]any{"foo": []string{"bar1", "bar2", "bar3"}},
850 },
851 {
852 // A comma-separated contract value merged with runtime values (which
853 // mergeRuntimeInputs joins with newlines) must still split the
854 // comma-joined line into separate values instead of collapsing it into
855 // a single literal glob containing commas.
856 name: "multiline input where a line is comma-separated",
857 inputs: map[string]string{"foo": "**/vendor/**,**/redist/**\nC:/a\nC:/b"},
858 expected: map[string]any{"foo": []string{"**/vendor/**", "**/redist/**", "C:/a", "C:/b"}},
859 },
860 {
861 name: "multiline input where several lines are comma-separated",
862 inputs: map[string]string{"foo": "a,b\nc,d\ne"},
863 expected: map[string]any{"foo": []string{"a", "b", "c", "d", "e"}},
864 },
865 {
866 name: "multiline input with escaped comma on a line",
867 inputs: map[string]string{"foo": "a\\,b,c\nd"},

Callers

nothing calls this directly

Calls 2

getInputArgumentsFunction · 0.85
RunMethod · 0.45

Tested by

no test coverage detected