Unit test for ListObjects in general.
(obj ObjectLayer, instanceType string, t1 TestErrHandler)
| 1746 | |
| 1747 | // Unit test for ListObjects in general. |
| 1748 | func testListObjectsContinuation(obj ObjectLayer, instanceType string, t1 TestErrHandler) { |
| 1749 | t, _ := t1.(*testing.T) |
| 1750 | testBuckets := []string{ |
| 1751 | // This bucket is used for testing ListObject operations. |
| 1752 | "test-bucket-list-object-continuation-1", |
| 1753 | "test-bucket-list-object-continuation-2", |
| 1754 | } |
| 1755 | for _, bucket := range testBuckets { |
| 1756 | err := obj.MakeBucket(context.Background(), bucket, MakeBucketOptions{}) |
| 1757 | if err != nil { |
| 1758 | t.Fatalf("%s : %s", instanceType, err.Error()) |
| 1759 | } |
| 1760 | } |
| 1761 | |
| 1762 | var err error |
| 1763 | testObjects := []struct { |
| 1764 | parentBucket string |
| 1765 | name string |
| 1766 | content string |
| 1767 | meta map[string]string |
| 1768 | }{ |
| 1769 | {testBuckets[0], "a/1.txt", "contentstring", nil}, |
| 1770 | {testBuckets[0], "a-1.txt", "contentstring", nil}, |
| 1771 | {testBuckets[0], "a.txt", "contentstring", nil}, |
| 1772 | {testBuckets[0], "apache2-doc/1.txt", "contentstring", nil}, |
| 1773 | {testBuckets[0], "apache2/1.txt", "contentstring", nil}, |
| 1774 | {testBuckets[0], "apache2/-sub/2.txt", "contentstring", nil}, |
| 1775 | {testBuckets[1], "azerty/1.txt", "contentstring", nil}, |
| 1776 | {testBuckets[1], "apache2-doc/1.txt", "contentstring", nil}, |
| 1777 | {testBuckets[1], "apache2/1.txt", "contentstring", nil}, |
| 1778 | } |
| 1779 | for _, object := range testObjects { |
| 1780 | md5Bytes := md5.Sum([]byte(object.content)) |
| 1781 | _, err = obj.PutObject(context.Background(), object.parentBucket, object.name, mustGetPutObjReader(t, bytes.NewBufferString(object.content), |
| 1782 | int64(len(object.content)), hex.EncodeToString(md5Bytes[:]), ""), ObjectOptions{UserDefined: object.meta}) |
| 1783 | if err != nil { |
| 1784 | t.Fatalf("%s : %s", instanceType, err.Error()) |
| 1785 | } |
| 1786 | |
| 1787 | } |
| 1788 | |
| 1789 | // Formulating the result data set to be expected from ListObjects call inside the tests, |
| 1790 | // This will be used in testCases and used for asserting the correctness of ListObjects output in the tests. |
| 1791 | |
| 1792 | resultCases := []ListObjectsInfo{ |
| 1793 | { |
| 1794 | Objects: []ObjectInfo{ |
| 1795 | {Name: "a-1.txt"}, |
| 1796 | {Name: "a.txt"}, |
| 1797 | {Name: "a/1.txt"}, |
| 1798 | {Name: "apache2-doc/1.txt"}, |
| 1799 | {Name: "apache2/-sub/2.txt"}, |
| 1800 | {Name: "apache2/1.txt"}, |
| 1801 | }, |
| 1802 | }, |
| 1803 | { |
| 1804 | Objects: []ObjectInfo{ |
| 1805 | {Name: "apache2-doc/1.txt"}, |
nothing calls this directly
no test coverage detected