| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
package ociunify |
| 16 |
|
| 17 |
import ( |
| 18 |
"cmp" |
| 19 |
"testing" |
| 20 |
|
| 21 |
"cuelabs.dev/go/oci/ociregistry" |
| 22 |
"github.com/go-quicktest/qt" |
| 23 |
) |
| 24 |
|
| 25 |
var mergeIterTests = []struct { |
| 26 |
testName string |
| 27 |
it0, it1 ociregistry.Seq[int] |
| 28 |
want []int |
| 29 |
wantErr error |
| 30 |
}{{ |
| 31 |
testName: "IdenticalContents", |
| 32 |
it0: ociregistry.SliceSeq([]int{1, 2, 3}), |
| 33 |
it1: ociregistry.SliceSeq([]int{1, 2, 3}), |
| 34 |
want: []int{1, 2, 3}, |
| 35 |
}, { |
| 36 |
testName: "DifferentContents", |
| 37 |
it0: ociregistry.SliceSeq([]int{0, 1, 2, 3}), |
| 38 |
it1: ociregistry.SliceSeq([]int{1, 2, 3, 5}), |
| 39 |
want: []int{0, 1, 2, 3, 5}, |
| 40 |
}, { |
| 41 |
testName: "NoItems", |
| 42 |
it0: ociregistry.SliceSeq[int](nil), |
| 43 |
it1: ociregistry.SliceSeq[int](nil), |
| 44 |
want: []int{}, |
| 45 |
}} |
| 46 |
|
| 47 |
func TestMergeIter(t *testing.T) { |
| 48 |
for _, test := range mergeIterTests { |
| 49 |
t.Run(test.testName, func(t *testing.T) { |
| 50 |
it := mergeIter(test.it0, test.it1, cmp.Compare) |
| 51 |
xs, err := ociregistry.All(it) |
| 52 |
qt.Assert(t, qt.DeepEquals(xs, test.want)) |
| 53 |
qt.Assert(t, qt.Equals(err, test.wantErr)) |
| 54 |
}) |
| 55 |
} |
| 56 |
} |