(r *http.Request, attributes ResourceAttributes)
| 29 | } |
| 30 | |
| 31 | func (h testResourceHandler) Create(r *http.Request, attributes ResourceAttributes) (Resource, error) { |
| 32 | // create unique identifier |
| 33 | rand.Seed(time.Now().UnixNano()) |
| 34 | id := fmt.Sprintf("%04d", rand.Intn(9999)) |
| 35 | |
| 36 | // store resource |
| 37 | h.data[id] = testData{ |
| 38 | resourceAttributes: attributes, |
| 39 | } |
| 40 | |
| 41 | now := time.Now() |
| 42 | |
| 43 | // return stored resource |
| 44 | return Resource{ |
| 45 | ID: id, |
| 46 | ExternalID: h.externalID(attributes), |
| 47 | Attributes: attributes, |
| 48 | Meta: Meta{ |
| 49 | Created: &now, |
| 50 | LastModified: &now, |
| 51 | Version: fmt.Sprintf("v%s", id), |
| 52 | }, |
| 53 | }, nil |
| 54 | } |
| 55 | |
| 56 | func (h testResourceHandler) Delete(r *http.Request, id string) error { |
| 57 | // check if resource exists |
nothing calls this directly
no test coverage detected