-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore: add basic tests * chore: add logger test
- Loading branch information
1 parent
072e6b6
commit 1e14e5f
Showing
17 changed files
with
327 additions
and
39 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
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 |
---|---|---|
|
@@ -4,3 +4,4 @@ main | |
cosmos-wallets-exporter | ||
dist/ | ||
**/.DS_Store | ||
cover.out |
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
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
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
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,48 @@ | ||
package logger | ||
|
||
import ( | ||
"main/pkg/config" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestGetDefaultLogger(t *testing.T) { | ||
t.Parallel() | ||
|
||
logger := GetDefaultLogger() | ||
require.NotNil(t, logger) | ||
} | ||
|
||
func TestGetLoggerInvalidLogLevel(t *testing.T) { | ||
t.Parallel() | ||
|
||
defer func() { | ||
if r := recover(); r == nil { | ||
require.Fail(t, "Expected to have a panic here!") | ||
} | ||
}() | ||
|
||
GetLogger(config.LogConfig{LogLevel: "invalid"}) | ||
} | ||
|
||
func TestGetLoggerValidPlain(t *testing.T) { | ||
t.Parallel() | ||
|
||
logger := GetLogger(config.LogConfig{LogLevel: "info"}) | ||
require.NotNil(t, logger) | ||
} | ||
|
||
func TestGetLoggerValidJSON(t *testing.T) { | ||
t.Parallel() | ||
|
||
logger := GetLogger(config.LogConfig{LogLevel: "info", JSONOutput: true}) | ||
require.NotNil(t, logger) | ||
} | ||
|
||
func TestGetLoggerNop(t *testing.T) { | ||
t.Parallel() | ||
|
||
logger := GetNopLogger() | ||
require.NotNil(t, logger) | ||
} |
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,37 @@ | ||
package tracing | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
|
||
"github.com/stretchr/testify/require" | ||
tracesdk "go.opentelemetry.io/otel/sdk/trace" | ||
) | ||
|
||
func TestNoopExporterShutdown(t *testing.T) { | ||
t.Parallel() | ||
|
||
exporter := NewNoopExporter() | ||
err := exporter.Shutdown(context.Background()) | ||
|
||
require.NoError(t, err) | ||
} | ||
|
||
func TestNoopExporterExportSpans(t *testing.T) { | ||
t.Parallel() | ||
|
||
exporter := NewNoopExporter() | ||
tp := NewTraceProvider(exporter, "1.2.3") | ||
|
||
_, span := tp.Tracer("test").Start(context.Background(), "test") | ||
defer span.End() | ||
|
||
readOnlySpan, ok := span.(tracesdk.ReadOnlySpan) | ||
assert.True(t, ok) | ||
|
||
err := exporter.ExportSpans(context.Background(), []tracesdk.ReadOnlySpan{readOnlySpan}) | ||
|
||
require.NoError(t, err) | ||
} |
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
Oops, something went wrong.