(t *testing.T)
| 15 | ) |
| 16 | |
| 17 | func TestTx_MoveBucket(t *testing.T) { |
| 18 | testCases := []struct { |
| 19 | name string |
| 20 | srcBucketPath []string |
| 21 | dstBucketPath []string |
| 22 | bucketToMove string |
| 23 | bucketExistInSrc bool |
| 24 | bucketExistInDst bool |
| 25 | hasIncompatibleKeyInSrc bool |
| 26 | hasIncompatibleKeyInDst bool |
| 27 | expectedErr error |
| 28 | }{ |
| 29 | // normal cases |
| 30 | { |
| 31 | name: "normal case", |
| 32 | srcBucketPath: []string{"sb1", "sb2"}, |
| 33 | dstBucketPath: []string{"db1", "db2"}, |
| 34 | bucketToMove: "bucketToMove", |
| 35 | bucketExistInSrc: true, |
| 36 | bucketExistInDst: false, |
| 37 | hasIncompatibleKeyInSrc: false, |
| 38 | hasIncompatibleKeyInDst: false, |
| 39 | expectedErr: nil, |
| 40 | }, |
| 41 | { |
| 42 | name: "the source and target bucket share the same grandparent", |
| 43 | srcBucketPath: []string{"grandparent", "sb2"}, |
| 44 | dstBucketPath: []string{"grandparent", "db2"}, |
| 45 | bucketToMove: "bucketToMove", |
| 46 | bucketExistInSrc: true, |
| 47 | bucketExistInDst: false, |
| 48 | hasIncompatibleKeyInSrc: false, |
| 49 | hasIncompatibleKeyInDst: false, |
| 50 | expectedErr: nil, |
| 51 | }, |
| 52 | { |
| 53 | name: "bucketToMove is a top level bucket", |
| 54 | srcBucketPath: []string{}, |
| 55 | dstBucketPath: []string{"db1", "db2"}, |
| 56 | bucketToMove: "bucketToMove", |
| 57 | bucketExistInSrc: true, |
| 58 | bucketExistInDst: false, |
| 59 | hasIncompatibleKeyInSrc: false, |
| 60 | hasIncompatibleKeyInDst: false, |
| 61 | expectedErr: nil, |
| 62 | }, |
| 63 | { |
| 64 | name: "convert bucketToMove to a top level bucket", |
| 65 | srcBucketPath: []string{"sb1", "sb2"}, |
| 66 | dstBucketPath: []string{}, |
| 67 | bucketToMove: "bucketToMove", |
| 68 | bucketExistInSrc: true, |
| 69 | bucketExistInDst: false, |
| 70 | hasIncompatibleKeyInSrc: false, |
| 71 | hasIncompatibleKeyInDst: false, |
| 72 | expectedErr: nil, |
| 73 | }, |
| 74 | // negative cases |
nothing calls this directly
no test coverage detected