(t *testing.T)
| 26 | ) |
| 27 | |
| 28 | func 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 | |
| 66 | func TestPostPolicySetKey(t *testing.T) { |
| 67 | tests := []struct { |
nothing calls this directly
no test coverage detected