Scott Baker | 104b67d | 2019-10-29 15:56:27 -0700 | [diff] [blame] | 1 | /* |
Joey Armstrong | 7f8436c | 2023-07-09 20:23:27 -0400 | [diff] [blame] | 2 | * Copyright 2018-2023 Open Networking Foundation (ONF) and the ONF Contributors |
Scott Baker | 104b67d | 2019-10-29 15:56:27 -0700 | [diff] [blame] | 3 | |
Joey Armstrong | 7f8436c | 2023-07-09 20:23:27 -0400 | [diff] [blame] | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
Scott Baker | 104b67d | 2019-10-29 15:56:27 -0700 | [diff] [blame] | 7 | |
Joey Armstrong | 7f8436c | 2023-07-09 20:23:27 -0400 | [diff] [blame] | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
Scott Baker | 104b67d | 2019-10-29 15:56:27 -0700 | [diff] [blame] | 9 | |
Joey Armstrong | 7f8436c | 2023-07-09 20:23:27 -0400 | [diff] [blame] | 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
Scott Baker | 104b67d | 2019-10-29 15:56:27 -0700 | [diff] [blame] | 15 | */ |
| 16 | package kafka |
| 17 | |
| 18 | import ( |
Neha Sharma | 94f16a9 | 2020-06-26 04:17:55 +0000 | [diff] [blame] | 19 | "context" |
Scott Baker | 104b67d | 2019-10-29 15:56:27 -0700 | [diff] [blame] | 20 | "github.com/stretchr/testify/assert" |
| 21 | "testing" |
| 22 | ) |
| 23 | |
| 24 | func TestSaramaClientEnableLivenessChannel(t *testing.T) { |
| 25 | // Note: This doesn't actually start the client |
| 26 | client := NewSaramaClient() |
| 27 | |
Neha Sharma | 94f16a9 | 2020-06-26 04:17:55 +0000 | [diff] [blame] | 28 | ch := client.EnableLivenessChannel(context.Background(), true) |
Scott Baker | 104b67d | 2019-10-29 15:56:27 -0700 | [diff] [blame] | 29 | |
| 30 | // The channel should have one "true" message on it |
| 31 | assert.NotEmpty(t, ch) |
| 32 | |
| 33 | select { |
| 34 | case stuff := <-ch: |
| 35 | assert.True(t, stuff) |
| 36 | default: |
| 37 | t.Error("Failed to read from the channel") |
| 38 | } |
| 39 | } |