MCPcopy
hub / github.com/minio/minio-go / TestPostPolicySetKeyStartsWith

Function TestPostPolicySetKeyStartsWith

post-policy_test.go:108–142  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

106}
107
108func TestPostPolicySetKeyStartsWith(t *testing.T) {
109 tests := []struct {
110 name string
111 input string
112 want string
113 }{
114 {
115 name: "valid key prefix",
116 input: "my-prefix/",
117 want: `["starts-with","$key","my-prefix/"]`,
118 },
119 {
120 name: "empty prefix (allow any key)",
121 input: "",
122 want: `["starts-with","$key",""]`,
123 },
124 }
125 for _, tt := range tests {
126 t.Run(tt.name, func(t *testing.T) {
127 pp := NewPostPolicy()
128
129 err := pp.SetKeyStartsWith(tt.input)
130 if err != nil {
131 t.Errorf("%s: want no error, got: %v", tt.name, err)
132 }
133
134 if tt.want != "" {
135 result := pp.String()
136 if !strings.Contains(result, tt.want) {
137 t.Errorf("%s: want result to contain: '%s', got: '%s'", tt.name, tt.want, result)
138 }
139 }
140 })
141 }
142}
143
144func TestPostPolicySetBucket(t *testing.T) {
145 tests := []struct {

Callers

nothing calls this directly

Calls 4

SetKeyStartsWithMethod · 0.95
StringMethod · 0.95
NewPostPolicyFunction · 0.85
ContainsMethod · 0.45

Tested by

no test coverage detected