(t *testing.T)
| 816 | } |
| 817 | |
| 818 | func TestMaxSubscriptionsPerTopic(t *testing.T) { |
| 819 | randomName := newTopicName() |
| 820 | topic := "persistent://public/default/" + randomName |
| 821 | cfg := &config.Config{} |
| 822 | admin, err := New(cfg) |
| 823 | assert.NoError(t, err) |
| 824 | assert.NotNil(t, admin) |
| 825 | topicName, err := utils.GetTopicName(topic) |
| 826 | assert.NoError(t, err) |
| 827 | err = admin.Topics().Create(*topicName, 4) |
| 828 | assert.NoError(t, err) |
| 829 | |
| 830 | // Get default max subscriptions per topic |
| 831 | maxSubscriptions, err := admin.Topics().GetMaxSubscriptionsPerTopic(*topicName) |
| 832 | assert.NoError(t, err) |
| 833 | assert.Equal(t, -1, maxSubscriptions) |
| 834 | |
| 835 | // Set new max subscriptions per topic |
| 836 | err = admin.Topics().SetMaxSubscriptionsPerTopic(*topicName, 100) |
| 837 | assert.NoError(t, err) |
| 838 | |
| 839 | // topic policy is an async operation, |
| 840 | // so we need to wait for a while to get current value |
| 841 | assert.Eventually( |
| 842 | t, |
| 843 | func() bool { |
| 844 | maxSubscriptions, err = admin.Topics().GetMaxSubscriptionsPerTopic(*topicName) |
| 845 | return err == nil && maxSubscriptions == 100 |
| 846 | }, |
| 847 | 10*time.Second, |
| 848 | 100*time.Millisecond, |
| 849 | ) |
| 850 | |
| 851 | // Remove max subscriptions per topic policy |
| 852 | err = admin.Topics().RemoveMaxSubscriptionsPerTopic(*topicName) |
| 853 | assert.NoError(t, err) |
| 854 | assert.Eventually( |
| 855 | t, |
| 856 | func() bool { |
| 857 | maxSubscriptions, err = admin.Topics().GetMaxSubscriptionsPerTopic(*topicName) |
| 858 | return err == nil && maxSubscriptions == -1 |
| 859 | }, |
| 860 | 10*time.Second, |
| 861 | 100*time.Millisecond, |
| 862 | ) |
| 863 | } |
| 864 | |
| 865 | func TestSchemaValidationEnforced(t *testing.T) { |
| 866 | randomName := newTopicName() |
nothing calls this directly
no test coverage detected
searching dependent graphs…