github.com/ydb-platform/ydb-go-sdk/v3@v3.57.0/topic/topicoptions/topicoptions_test.go (about) 1 package topicoptions 2 3 import ( 4 "testing" 5 "time" 6 7 "github.com/stretchr/testify/assert" 8 ) 9 10 func TestEqualAlterOptions(t *testing.T) { 11 for _, tt := range []struct { 12 lhs []AlterOption 13 rhs []AlterOption 14 }{ 15 { 16 []AlterOption{ 17 AlterConsumerWithImportant("name", true), 18 AlterConsumerWithReadFrom("name", time.Unix(0, 0)), 19 }, 20 []AlterOption{ 21 AlterConsumerWithImportant("name", true), 22 AlterConsumerWithReadFrom("name", time.Unix(0, 0)), 23 }, 24 }, 25 { 26 []AlterOption{ 27 AlterConsumerWithImportant("name", true), 28 AlterConsumerWithReadFrom("name", time.Unix(0, 0)), 29 }, 30 []AlterOption{ 31 AlterConsumerWithReadFrom("name", time.Unix(0, 0)), 32 AlterConsumerWithImportant("name", true), 33 }, 34 }, 35 { 36 []AlterOption{ 37 AlterConsumerWithImportant("name", true), 38 AlterWithMinActivePartitions(15), 39 AlterConsumerWithReadFrom("name", time.Unix(0, 0)), 40 }, 41 []AlterOption{ 42 AlterConsumerWithReadFrom("name", time.Unix(0, 0)), 43 AlterConsumerWithImportant("name", true), 44 AlterWithMinActivePartitions(15), 45 }, 46 }, 47 { 48 []AlterOption{ 49 AlterConsumerWithImportant("name", true), 50 AlterConsumerWithReadFrom("name", time.Unix(0, 0)), 51 AlterWithDropConsumers("a", "b"), 52 }, 53 []AlterOption{ 54 AlterConsumerWithImportant("name", true), 55 AlterConsumerWithReadFrom("name", time.Unix(0, 0)), 56 AlterWithDropConsumers("a", "b"), 57 }, 58 }, 59 { 60 []AlterOption{ 61 AlterConsumerWithImportant("name", true), 62 AlterConsumerWithReadFrom("name", time.Unix(0, 0)), 63 AlterWithDropConsumers("b", "a"), 64 }, 65 []AlterOption{ 66 AlterConsumerWithImportant("name", true), 67 AlterConsumerWithReadFrom("name", time.Unix(0, 0)), 68 AlterWithDropConsumers("a", "b"), 69 }, 70 }, 71 } { 72 t.Run("", func(t *testing.T) { 73 assert.ElementsMatch(t, tt.lhs, tt.rhs) // compare slices with ignore ordering 74 }) 75 } 76 } 77 78 func TestEqualCreateOptions(t *testing.T) { 79 for _, tt := range []struct { 80 lhs []CreateOption 81 rhs []CreateOption 82 }{ 83 { 84 []CreateOption{ 85 CreateWithMeteringMode(1), 86 CreateWithPartitionCountLimit(100), 87 CreateWithRetentionPeriod(5), 88 }, 89 []CreateOption{ 90 CreateWithRetentionPeriod(5), 91 CreateWithMeteringMode(1), 92 CreateWithPartitionCountLimit(100), 93 }, 94 }, 95 } { 96 t.Run("", func(t *testing.T) { 97 assert.ElementsMatch(t, tt.lhs, tt.rhs) // compare slices with ignore ordering 98 }) 99 } 100 }