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

Function TestPostPolicySetExpires

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

Source from the content-addressed store, hash-verified

26)
27
28func TestPostPolicySetExpires(t *testing.T) {
29 tests := []struct {
30 name string
31 input time.Time
32 wantErr bool
33 wantResult string
34 }{
35 {
36 name: "valid time",
37 input: time.Date(2023, time.March, 2, 15, 4, 5, 0, time.UTC),
38 wantErr: false,
39 wantResult: "2023-03-02T15:04:05",
40 },
41 {
42 name: "time before 1970",
43 input: time.Date(1, time.January, 1, 0, 0, 0, 0, time.UTC),
44 wantErr: true,
45 },
46 }
47 for _, tt := range tests {
48 t.Run(tt.name, func(t *testing.T) {
49 pp := NewPostPolicy()
50
51 err := pp.SetExpires(tt.input)
52 if (err != nil) != tt.wantErr {
53 t.Errorf("%s: want error: %v, got: %v", tt.name, tt.wantErr, err)
54 }
55
56 if tt.wantResult != "" {
57 result := pp.String()
58 if !strings.Contains(result, tt.wantResult) {
59 t.Errorf("%s: want result to contain: '%s', got: '%s'", tt.name, tt.wantResult, result)
60 }
61 }
62 })
63 }
64}
65
66func TestPostPolicySetKey(t *testing.T) {
67 tests := []struct {

Callers

nothing calls this directly

Calls 4

SetExpiresMethod · 0.95
StringMethod · 0.95
NewPostPolicyFunction · 0.85
ContainsMethod · 0.45

Tested by

no test coverage detected