(obj ObjectLayer, instanceType, bucketName string, apiRouter http.Handler, credentials auth.Credentials, t *testing.T, )
| 65 | } |
| 66 | |
| 67 | func testAPIHeadObjectHandler(obj ObjectLayer, instanceType, bucketName string, apiRouter http.Handler, |
| 68 | credentials auth.Credentials, t *testing.T, |
| 69 | ) { |
| 70 | objectName := "test-object" |
| 71 | // set of byte data for PutObject. |
| 72 | // object has to be created before running tests for HeadObject. |
| 73 | // this is required even to assert the HeadObject data, |
| 74 | // since dataInserted === dataFetched back is a primary criteria for any object storage this assertion is critical. |
| 75 | bytesData := []struct { |
| 76 | byteData []byte |
| 77 | }{ |
| 78 | {generateBytesData(6 * humanize.MiByte)}, |
| 79 | } |
| 80 | // set of inputs for uploading the objects before tests for downloading is done. |
| 81 | putObjectInputs := []struct { |
| 82 | bucketName string |
| 83 | objectName string |
| 84 | contentLength int64 |
| 85 | textData []byte |
| 86 | metaData map[string]string |
| 87 | }{ |
| 88 | {bucketName, objectName, int64(len(bytesData[0].byteData)), bytesData[0].byteData, make(map[string]string)}, |
| 89 | } |
| 90 | // iterate through the above set of inputs and upload the object. |
| 91 | for i, input := range putObjectInputs { |
| 92 | // uploading the object. |
| 93 | _, err := obj.PutObject(context.Background(), input.bucketName, input.objectName, mustGetPutObjReader(t, bytes.NewReader(input.textData), input.contentLength, input.metaData[""], ""), ObjectOptions{UserDefined: input.metaData}) |
| 94 | // if object upload fails stop the test. |
| 95 | if err != nil { |
| 96 | t.Fatalf("Put Object case %d: Error uploading object: <ERROR> %v", i+1, err) |
| 97 | } |
| 98 | } |
| 99 | |
| 100 | // test cases with inputs and expected result for HeadObject. |
| 101 | testCases := []struct { |
| 102 | bucketName string |
| 103 | objectName string |
| 104 | accessKey string |
| 105 | secretKey string |
| 106 | // expected output. |
| 107 | expectedRespStatus int // expected response status body. |
| 108 | }{ |
| 109 | // Test case - 1. |
| 110 | // Fetching stat info of object and validating it. |
| 111 | { |
| 112 | bucketName: bucketName, |
| 113 | objectName: objectName, |
| 114 | accessKey: credentials.AccessKey, |
| 115 | secretKey: credentials.SecretKey, |
| 116 | expectedRespStatus: http.StatusOK, |
| 117 | }, |
| 118 | // Test case - 2. |
| 119 | // Case with non-existent object name. |
| 120 | { |
| 121 | bucketName: bucketName, |
| 122 | objectName: "abcd", |
| 123 | accessKey: credentials.AccessKey, |
| 124 | secretKey: credentials.SecretKey, |
nothing calls this directly
no test coverage detected