-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[iman] testing for command producer and consumer
- Loading branch information
Iman Tung
committed
Jun 11, 2018
1 parent
5ae3115
commit b68b7cd
Showing
3 changed files
with
70 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package cmds | ||
|
||
import ( | ||
"os" | ||
"testing" | ||
|
||
. "github.com/BaritoLog/go-boilerplate/testkit" | ||
"github.com/BaritoLog/instru" | ||
log "github.com/sirupsen/logrus" | ||
) | ||
|
||
func TestConsumer(t *testing.T) { | ||
log.SetLevel(log.ErrorLevel) | ||
os.Setenv(EnvKafkaBrokers, "wronghost:2349") | ||
defer os.Clearenv() | ||
|
||
err := Consumer(nil) | ||
|
||
FatalIfWrongError(t, err, "kafka: client has run out of available brokers to talk to (Is your cluster reachable?)") | ||
} | ||
|
||
func TestCallbackInstrumentation(t *testing.T) { | ||
|
||
FatalIf(t, callbackInstrumentation(), "it should be return false") | ||
|
||
os.Setenv(EnvPushMetricToken, "some-token") | ||
os.Setenv(EnvPushMetricUrl, "http://some-url") | ||
FatalIf(t, !callbackInstrumentation(), "it should be return true") | ||
FatalIf(t, instru.DefaultCallback == nil, "it should be set callback") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package cmds | ||
|
||
import ( | ||
"os" | ||
"testing" | ||
|
||
. "github.com/BaritoLog/go-boilerplate/testkit" | ||
log "github.com/sirupsen/logrus" | ||
) | ||
|
||
func TestProducer(t *testing.T) { | ||
log.SetLevel(log.ErrorLevel) | ||
os.Setenv(EnvKafkaBrokers, "wronghost:2349") | ||
defer os.Clearenv() | ||
|
||
err := Producer(nil) | ||
FatalIfWrongError(t, err, "kafka: client has run out of available brokers to talk to (Is your cluster reachable?)") | ||
} |